You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe any alternatives/workarounds you're currently using
I have just experience a change detection bug where an event was being triggered in such a way that it was running outside of NgZone. The event would trigger actions and update the store but the template would not be updated. The bug only surfaced as a setInterval was removed which had the effect of ensuring ChangeDetection was consistently run.
Adding the following meta reducer immediately highlighted the problem code.
//NgRx Meta Reducer to assert always in NgZoneexportfunctionassertInNgZoneMetaReducer(reducer){returnfunction(state: State,action: Action): State{NgZone.assertInAngularZone();returnreducer(state,action);};}
Having a built-in check that mimics this behaviour could be extremely valuable at catching issues in development. I believe it would have helped catch some of the errors reported in #476.
Other information:
I understand that there will be cases where this is not a valid check as developers can explicitly choose to run code outside of ngZone so this would have to be configurable. However, my assumption would be that for the majority of apps an event running outside of ngZone is a red flag and not intentional.
If accepted, I would be willing to submit a PR for this feature
[X] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered:
Trying to decide on the default status of this runtime check.
Defaulting on would mean higher uptake of this feature and potentially help catch more issues. My assumption would be that 'most' apps are written without an explicit need to run events outside of NgZone, meaning any events this catches would be of use to users.
On the flip side defaulting on would cause errors to start being thrown for apps that do explicitly run events outside of NgZone and require toggling this runtime check off.
Describe any alternatives/workarounds you're currently using
I have just experience a change detection bug where an event was being triggered in such a way that it was running outside of NgZone. The event would trigger actions and update the store but the template would not be updated. The bug only surfaced as a setInterval was removed which had the effect of ensuring ChangeDetection was consistently run.
Adding the following meta reducer immediately highlighted the problem code.
Having a built-in check that mimics this behaviour could be extremely valuable at catching issues in development. I believe it would have helped catch some of the errors reported in #476.
Other information:
I understand that there will be cases where this is not a valid check as developers can explicitly choose to run code outside of ngZone so this would have to be configurable. However, my assumption would be that for the majority of apps an event running outside of ngZone is a red flag and not intentional.
If accepted, I would be willing to submit a PR for this feature
[X] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered: