index.js
function expose(){

    // TODO test this
    // if(!isDefined(defaultValue)){
    //  throw new Error("model.addPublicProperty() is being " +
    //    "invoked with an undefined default value. Default values for exposed properties " +
    //    "must be defined, to guarantee predictable behavior. For exposed properties that " +
    //    "are optional and should have the semantics of an undefined value, " +
    //    "use null as the default value.");
    //}

    // TODO test this
    if(!lastPropertyAdded){
      throw Error("Expose() was called without first adding a property.");
    }

    var propertyName = lastPropertyAdded;

    if(!exposedProperties){
      exposedProperties = [];
    }
    exposedProperties.push(propertyName);

    // Destroy the previous reactive function that was listening for changes
    // in all exposed properties except the newly added one.
    // TODO think about how this might be done only once, at the same time isFinalized is set.
    if(configurationReactiveFunction){
      configurationReactiveFunction.destroy();
    }

    // Set up the new reactive function that will listen for changes
    // in all exposed properties including the newly added one.
    var inputPropertyNames = exposedProperties;

    //console.log(inputPropertyNames);
    configurationReactiveFunction = ReactiveFunction({
      inputs: inputPropertyNames.map(getProperty),
      output: configurationProperty,
      callback: function (){
        var configuration = {};
        inputPropertyNames.forEach(function (propertyName){
          var property = getProperty(propertyName);

          // Omit default values from the returned configuration object.
          if(property() !== property.default()){
            configuration[propertyName] = property();
          }
        });
        return configuration;
      }
    });

    // Support method chaining.
    return model;
  }
function expose(){

    // TODO test this
    // if(!isDefined(defaultValue)){
    //  throw new Error("model.addPublicProperty() is being " +
    //    "invoked with an undefined default value. Default values for exposed properties " +
    //    "must be defined, to guarantee predictable behavior. For exposed properties that " +
    //    "are optional and should have the semantics of an undefined value, " +
    //    "use null as the default value.");
    //}

    // TODO test this
    if(!lastPropertyAdded){
      throw Error("Expose() was called without first adding a property.");
    }

    var propertyName = lastPropertyAdded;

    if(!exposedProperties){
      exposedProperties = [];
    }
    exposedProperties.push(propertyName);

    // Destroy the previous reactive function that was listening for changes
    // in all exposed properties except the newly added one.
    // TODO think about how this might be done only once, at the same time isFinalized is set.
    if(configurationReactiveFunction){
      configurationReactiveFunction.destroy();
    }

    // Set up the new reactive function that will listen for changes
    // in all exposed properties including the newly added one.
    var inputPropertyNames = exposedProperties;

    //console.log(inputPropertyNames);
    configurationReactiveFunction = ReactiveFunction({
      inputs: inputPropertyNames.map(getProperty),
      output: configurationProperty,
      callback: function (){
        var configuration = {};
        inputPropertyNames.forEach(function (propertyName){
          var property = getProperty(propertyName);

          // Omit default values from the returned configuration object.
          if(property() !== property.default()){
            configuration[propertyName] = property();
          }
        });
        return configuration;
      }
    });

    // Support method chaining.
    return model;
  }
function expose ( ) { // TODO test this // if(!isDefined(defaultValue)){ //  throw new Error("model.addPublicProperty() is being " + //    "invoked with an undefined default value. Default values for exposed properties " + //    "must be defined, to guarantee predictable behavior. For exposed properties that " + //    "are optional and should have the semantics of an undefined value, " + //    "use null as the default value."); //} // TODO test this if ( ! lastPropertyAdded ) { throw Error ( "Expose() was called without first adding a property." ) ; } var propertyName = lastPropertyAdded ; if ( ! exposedProperties ) { exposedProperties = [ ] ; } exposedProperties . push ( propertyName ) ; // Destroy the previous reactive function that was listening for changes // in all exposed properties except the newly added one. // TODO think about how this might be done only once, at the same time isFinalized is set. if ( configurationReactiveFunction ) { configurationReactiveFunction . destroy ( ) ; } // Set up the new reactive function that will listen for changes // in all exposed properties including the newly added one. var inputPropertyNames = exposedProperties ; //console.log(inputPropertyNames); configurationReactiveFunction = ReactiveFunction ( { inputs : inputPropertyNames . map ( getProperty ) , output : configurationProperty , callback : function ( ) { var configuration = { } ; inputPropertyNames . forEach ( function ( propertyName ) { var property = getProperty ( propertyName ) ; // Omit default values from the returned configuration object. if ( property ( ) !== property . default ( ) ) { configuration [ propertyName ] = property ( ) ; } } ) ; return configuration ; } } ) ; // Support method chaining. return model ; }
Exposes the last added property to the configuration.
Exposes the last added property to the configuration .