DEV Community

Discussion on: Change Detection: Getting in the (Angular) Zone!

Collapse
 
scooperdev profile image
Stephen Cooper

As I am using NgRx in this current app and we do not run anything purposefully outside of NgZone we can add a check. The following meta reducer checks that every event that updates the store is in Angular's zone. Reverting my fix and adding this makes it very easy to locate the source of my issue.

//NgRx Meta Reducer to assert always in NgZone
export function assertInNgZoneMetaReducer(reducer) {
    return function(state: State, action: Action): State {
        NgZone.assertInAngularZone();
        return reducer(state, action);
    };
}
Collapse
 
scooperdev profile image
Stephen Cooper