1. For the store understanding:
Http://cn.mobx.js.org/best/store.html
In complex projects, you can consider introducing Rootstore and provider to manage all the store;
The UI store can be used to do some global related processing, such as loading, screen size changes, and theme settings.
2. Based on the flexibility of coding, it is more convenient to modify the properties without adding use strict.
3. Class internal state can be completely replaced with this.xxx, in front plus @observerable, very convenient, class itself with @observer decoration. That is, this class is an observer, and it also observes the attributes within this class, such as the Watchon here:
@ observable Watchon = false; The initialization of internal properties is also simple: watch = new Watchstore ();
This allows you to get out of bondage and write the purest code (note the lifecycle). )
4. Questions TODO:
Componentwillreact ... In RN, if it works?
Action.bound something.
Atom what scenario to use.
5. Use of reaction:
Http://cn.mobx.js.org/refguide/reaction.html
This.savehandler = reaction (
///observe anything used in JSON:
() => This.asjson,
//How AutoSave is True, send JSON to the server
(JSON) => {
if (this.autosave) {
This.store.transportLayer.saveTodo (JSON);
}
}
);
The second method runs when and only if This.asjson returns a new value, and the value returned by This.asjson is the parameter JSON for the second method.
Its usage needs to be realized in practice.
6. Use of Autorun and its comparison with reaction
Constructor () {
Mobx.autorun (() => Console.log (This.report));
}
Autorun I understand is similar to a trigger in which all observable objects that are used will trigger its operation once it has changed. Reaction has something in common with it, but based on a change in the value of an expression and then triggers an action based on that value, it should be noted that the latter action will not be triggered by other observable objects it uses, which is different from the autorun.