mobx
mobx copied to clipboard
Disposer of async reactions should also cancel pending sideeffect/action
When disposer of autorunAsync or reaction is called after there was a change in their tracked inputs, action/sideEffect is still triggered:
//... a is observable...
this.a = 1;
const dispose = reaction(() => this.a, () => console.log('Reaction run.'), {delay: 1});
this.a = 2;
dispose();
// ... Now 'Reaction run.' will still be printed out.
For me the expected behavior would be that calling the disposer also cancels internal timeout.
Agreed, PR is welcome :)
Fixed in MobX4