Currently delving into the world of mobx and runInAction, facing a challenge in comprehending why autorun fails to trigger my callback in this particular scenario:
class ExampleClass {
// constructor() {
// this.exampleMethod();
// }
@observable myBoolean = false;
async exampleMethod() {
await new Promise(resolve => setTimeout(resolve, 1000));
runInAction(() => this.myBoolean = true); // <--- myBoolean: true never gets logged to the console. why?
await new Promise(resolve => setTimeout(resolve, 3000));
runInAction(() => this.myBoolean = false); // <--- still not being logged
}
}
let example = new ExampleClass();
example.exampleMethod();
autorun(() => console.log("myBoolean:", example.myBoolean));
Employing TypeScript and babel alongside decorators.
My understanding dictates that runInAction(...) aids in modifying observables when outside of an action-marked method?
What could be causing the malfunction in my script?