Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 1385x 1385x | import knockout from "./ThirdParty/knockout.js";
/**
* Subscribe to a Knockout observable ES5 property, and immediately fire
* the callback with the current value of the property.
*
* @private
*
* @function 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 {string} [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.
*/
function subscribeAndEvaluate(
owner,
observablePropertyName,
callback,
target,
event,
) {
callback.call(target, owner[observablePropertyName]);
return knockout
.getObservable(owner, observablePropertyName)
.subscribe(callback, target, event);
}
export default subscribeAndEvaluate;
|