July 2018
Beginner
236 pages
5h 34m
English
Now that the core observable state has been established, we can give some consideration to the derived state. Derived state (derivations) are computed properties that depend on other observables. It is helpful to think of the derivations in the context of how the core observable state is consumed.
One common use case when you have arrays is to think of the empty state. There is usually some visual indication that the list is empty. Rather than testing the array.length, which is quite low-level, it is better to expose a computed property called isEmpty. Such computed properties focus on the semantics of our store rather than dealing directly with the core observables:
class WishListStore { @observable.shallow lists = []; @computed ...
Read now
Unlock full access