The functional reactive "when" operator.  * `properties` An array of property names (can also be a single property string). * `callback` A callback function that is called: * with property values as arguments, ordered corresponding to the properties array, * only if all specified properties have values, * once for initialization, * whenever one or more specified properties change, * on the next tick of the JavaScript event loop after properties change, * only once as a result of one or more synchronous changes to dependency properties.
function when(properties, callback){

      // This function will trigger the callback to be invoked.
      var triggerCallback = debounce(function (){
        var args = properties.map(function(property){
          return values[property];
        });
        if(allAreDefined(args)){
          callback.apply(null, args);
        }
      });

      // Handle either an array or a single string.
      properties = (properties instanceof Array) ? properties : [properties];

      // Trigger the callback once for initialization.
      triggerCallback();
      
      // Trigger the callback whenever specified properties change.
      properties.forEach(function(property){
        on(property, triggerCallback);
      });
    }