mobx icon indicating copy to clipboard operation
mobx copied to clipboard

Disposer of async reactions should also cancel pending sideeffect/action

Open ptomask opened this issue 9 years ago • 2 comments

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.

ptomask avatar Aug 23 '17 10:08 ptomask

Agreed, PR is welcome :)

mweststrate avatar Sep 05 '17 14:09 mweststrate

Fixed in MobX4

mweststrate avatar Feb 27 '18 10:02 mweststrate