From 420e1f5ddb5606d6f0e87b5d490d2313dd0c99cc Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 2 Oct 2018 11:24:26 +0100 Subject: [PATCH 1/3] feat(store-devtools): use different action when recomputing state history --- modules/store-devtools/src/reducer.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/store-devtools/src/reducer.ts b/modules/store-devtools/src/reducer.ts index 97dc22a67e..0b5f564c17 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/recomput-state' as '@ngrx/devtools/recomput-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; From 0520680df1fad132c77d6bae7c7ffe3c1df64931 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 3 Oct 2018 15:24:50 +0100 Subject: [PATCH 2/3] correct spelling --- modules/store-devtools/src/reducer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/store-devtools/src/reducer.ts b/modules/store-devtools/src/reducer.ts index 0b5f564c17..547a1dc015 100644 --- a/modules/store-devtools/src/reducer.ts +++ b/modules/store-devtools/src/reducer.ts @@ -25,7 +25,7 @@ export type Actions = DevtoolsActions.All | CoreActions; export const INIT_ACTION = { type: INIT }; -export const RECOMPUTE_STATE = '@ngrx/devtools/recomput-state' as '@ngrx/devtools/recomput-state'; +export const RECOMPUTE_STATE = '@ngrx/devtools/recompute-state' as '@ngrx/devtools/recompute-state'; export const RECOMPUTE_STATE_ACTION = { type: RECOMPUTE_STATE }; export interface ComputedState { From 6daadad6b1acf790967490af6ce38cb4c50a95ff Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 3 Oct 2018 16:52:31 +0100 Subject: [PATCH 3/3] add test --- modules/store-devtools/spec/store.spec.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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;