The cycle of derivation

MobX uses a globalState to keep a reference to the currently executing derivation or reaction. Whenever a reaction is running, all observables that fire their reportObserved() will be tagged to this reaction. In fact, the relationship is bi-directional. An observable keeps track of all of its observers (reactions), while a reaction keeps track of all the observables it is currently observing. The currently executing reaction will be added as an observer for each of the observables. If the observer was already added, it will be ignored.

The observers all give back a disposer function when you set them up. We have already seen this with the return values of autorun(), reaction(), or when(), which are disposer functions. ...

Get MobX Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.