mobxjs / mobx-angular

The MobX connector for Angular.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

changeDetection is not triggered after delayed operations (setTimeout, RxJS, etc)

YugasVasyl opened this issue · comments

Hi! Currently, I'm using Angular 9 with mobx-angular 3.1.1 and everything is working fine. But I would like to upgrade Angular to 11 or 12. So I downloaded a simple Angular 12 project and tested if mobx is working fine there and faced the next problem.
I'm using mobx with directive *mobxAutorun + "changeDetection: ChangeDetectionStrategy.OnPush" and it works, but looks like any delayed operations are not triggering changeDetection when fired, for example, setTimeout, or any operation with RxJS. Such things worked well with Angular 9 and mobx 3.1.1, but don't work on Angular 11 and 12 with mobx-angular 4.2.0 and mobx 6.0.0.

Here is a simple example with setTimeout issue:
https://stackblitz.com/edit/angular-ivy-fakbnk?file=src/app/app.component.html

I would appreciate any help with that, thanks.

I see that my issue is fixable with makeAutoObservable(this); which I've missed