Nugget 2: Force a Computed KO observable to re-compute by using notifications
What is interesting in this nugget is that there is communication between the above two models via a computed observable property in one of the models. Note that wristWatch has a reference to an observable property of the injected model, question. Line 5 prints true because the property is observable. When askTime in the curiousVisitor model is invoked all subscribers to question are notified. Because this observable is now a dependent observable in line 8, the observable is emitted here, in the body of the computed observable, and the property is recalculated.
Comments
Post a Comment