Sha256: 243215699b0aaf8bc8a19f5b73d86f1bfe629955ff2cc158425dabb46486ff93

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

/*global define*/
define(['ThirdParty/knockout'], function(
        knockout) {
    "use strict";

    /**
     * Subscribe to a Knockout observable ES5 property, and immediately fire
     * the callback with the current value of the property.
     *
     * @private
     *
     * @exports subscribeAndEvaluate
     *
     * @param {Object} owner The object containing the observable property.
     * @param {String} observablePropertyName The name of the observable property.
     * @param {Function} callback The callback function.
     * @param {Object} [target] The value of this in the callback function.
     * @param {Function} [event='change'] The name of the event to receive notification for.
     *
     * @returns The subscription object from Knockout which can be used to dispose the subscription later.
     */
    var subscribeAndEvaluate = function(owner, observablePropertyName, callback, target, event) {
        callback.call(target, owner[observablePropertyName]);
        return knockout.getObservable(owner, observablePropertyName).subscribe(callback, target, event);
    };

    return subscribeAndEvaluate;
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cesium-0.25.0 app/assets/javascripts/Widgets/subscribeAndEvaluate.js
cesium-0.24.1 app/assets/javascripts/Widgets/subscribeAndEvaluate.js
cesium-0.24.0 app/assets/javascripts/Widgets/subscribeAndEvaluate.js
cesium-0.23.0 app/assets/javascripts/Widgets/subscribeAndEvaluate.js
cesium-0.22.0 app/assets/javascripts/Widgets/subscribeAndEvaluate.js