July 2018
Beginner
236 pages
5h 34m
English
ObservableValue is a subclass of Atom that adds the ability to store the value of the observable. It also adds a few more capabilities such as providing hooks for intercepting a value change and observing the value. This is also part of the definition for ObservableValue. Here is a simplified definition of ObservableValue:
class ObservableValue extends Atom { value; get() { /* ... */ this.reportObserved(); } set(value) { /* Pass through interceptor, which may modify the value (newValue) ... */ this.value = newValue; this.reportChanged(); } intercept(handler) {} observe(listener, fireImmediately) {}}
Notice the calls to reportObserved() in the get() method and reportChanged() in the set() method. These are the places where ...
Read now
Unlock full access