mobxjs / mobx-angular

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

Observables without initial value aren't updated correctly #140

Closed YugasVasyl closed 1 year ago

YugasVasyl commented 3 years ago

Recently I have updated angular to version 12 and angular-mobx to the latest and mentioned, that some of my pages don't work at all. After investigation, I find out what is the problem. On my project, I'm using mobx in combination with decorators (@observables...) and ChangeDetectionStrategy.OnPush. I also added makeObservable(this) to all my components that use mobx decorators. And I mentioned, that mobx doesn't update delayed (API calls, timeout, etc) actions when observable doesn't have an initial value.

You can check the issue here: https://angular-ymwswe.stackblitz.io There is @observable someString, which is updated in setTimeout, and if someString didn't have an initial value, it will not be rendered, but if it has any value (even undefined) it works as expected.

I'm just curious if that's a library issue or expected behavior? If it's expected I would suggest adding some mention or warning about it README, so users know about it.

theoklitosBam7 commented 2 years ago

As the MobX documentation states regarding limitations: