mobxjs / mobx-angular

The MobX connector for Angular.
MIT License
483 stars 59 forks source link

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

Closed YugasVasyl closed 3 years ago

YugasVasyl commented 3 years ago

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.

YugasVasyl commented 3 years ago

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