diff --git a/modules/store-devtools/spec/store.spec.ts b/modules/store-devtools/spec/store.spec.ts index 1e005c0609..de5ef3432c 100644 --- a/modules/store-devtools/spec/store.spec.ts +++ b/modules/store-devtools/spec/store.spec.ts @@ -17,6 +17,7 @@ import { } from '../'; import { IS_EXTENSION_OR_MONITOR_PRESENT } from '../src/instrument'; import { PerformAction } from '../src/actions'; +import { RECOMPUTE_STATE } from '../src/reducer'; const counter = jasmine .createSpy('counter') @@ -126,6 +127,20 @@ function createStore( } describe('Store Devtools', () => { + describe('reducer', () => { + it('should call @ngrx/devtools/recompute-state action', () => { + const fixture = createStore(doubleCounter); + counter.calls.reset(); + fixture.replaceReducer(counter); + + const allArgs = counter.calls.allArgs(); + expect(allArgs.length).toEqual(3); + expect(allArgs[0][1].type).toEqual(UPDATE); + expect(allArgs[1][1].type).toEqual(RECOMPUTE_STATE); + expect(allArgs[2][1].type).toEqual(RECOMPUTE_STATE); + }); + }); + describe('Instrumentation', () => { let fixture: Fixture; let store: Store; diff --git a/modules/store-devtools/src/reducer.ts b/modules/store-devtools/src/reducer.ts index 97dc22a67e..547a1dc015 100644 --- a/modules/store-devtools/src/reducer.ts +++ b/modules/store-devtools/src/reducer.ts @@ -25,6 +25,9 @@ export type Actions = DevtoolsActions.All | CoreActions; export const INIT_ACTION = { type: INIT }; +export const RECOMPUTE_STATE = '@ngrx/devtools/recompute-state' as '@ngrx/devtools/recompute-state'; +export const RECOMPUTE_STATE_ACTION = { type: RECOMPUTE_STATE }; + export interface ComputedState { state: any; error: any; @@ -501,7 +504,7 @@ export function liftReducerWith( // Recompute state history with latest reducer and update action computedStates = computedStates.map(cmp => ({ ...cmp, - state: reducer(cmp.state, liftedAction), + state: reducer(cmp.state, RECOMPUTE_STATE_ACTION), })); currentStateIndex = stagedActionIds.length - 1;