I have a store myStore
which has a main
method which invokes multiple methods which are setting observale value in mobx. My problem is I want to re-render my react component only after ALL the observables are set.
can I make the main method @action
, even though it doesn't actually modify any observables directly? what is the standard practice for such scenarios ?
class myStore {
@observable var1;
@observable var2;
@action method1(val) {
this.var1 = val;
}
@action mathod2(val) {
this.var2 = val;
}
main() {
this.method1("some random value 1"); // Mobx may re-render the react component just after this line
this.method2("some random value 2");
// I want to re-render the component here(at the end of method)
}
}