July 2018
Beginner
236 pages
5h 34m
English
reaction() is yet another kind of reaction in MobX. Yes, the choice of the API name was intentional. reaction() is similar to autorun() but waits for a change in the observables before executing the effect-function. reaction() in fact takes two arguments, which are as follows:
reaction(tracker-function, effect-function): disposer-functiontracker-function: () => data, effect-function: (data) => {}
tracker-function is where all the observables are tracked. Any time the tracked observables change, it will re-execute. It is supposed to return a value that is used to compare it to the previous run of tracker-function. If these return-values differ, the effect-function is executed.
By breaking up the activity of a reaction into a change-detecting ...
Read now
Unlock full access