If I set a break point inside a knockout.js computed, I see two frames in the call stack (using Chrome's F12 facility)
function evaluateImmediate()
at var newValue = readFunction.call(evaluatorFunctionTarget);
I believe knockout defers/throttles computed evaluation using a timeout mechanism. They must be storing the trigger(s) that caused the computed to re-evaluate, yes? Where?
Is there also a "remembered" context that is available to the evaluating computed? Where?
Whenever you declare a computed observable, KO immediately invokes its evaluator function to get its initial value. While the evaluator function is running, KO sets up a subscription to any observables (including other computed observables) that the evaluator reads.
Knockout. js defines an important role when we want to detect and respond to changes on one object, we uses the observable. An observable is useful in various scenarios where we are displaying or editing multiple values and require repeated sections of the UI to appear and disappear as items are inserted and deleted.
Computed Observable is a function which is dependent on one or more Observables and automatically updates whenever its underlying Observables (dependencies) change. Computed Observables can be chained.
Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model.
If you are using the throttle
extender then yes the evaluation is deferred. But the reason the evaluation was triggered is not stored. It is unusual, when using Knockout, to care about which dependency triggered your evaluation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With