Skip to content

Commit 1448a0e

Browse files
tja4472brandonroberts
authored andcommitted
feat(store-devtools): use different action when recomputing state history (#1353)
Closes #1255
1 parent 41a0d45 commit 1448a0e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

modules/store-devtools/spec/store.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from '../';
1818
import { IS_EXTENSION_OR_MONITOR_PRESENT } from '../src/instrument';
1919
import { PerformAction } from '../src/actions';
20+
import { RECOMPUTE_STATE } from '../src/reducer';
2021

2122
const counter = jasmine
2223
.createSpy('counter')
@@ -126,6 +127,20 @@ function createStore<T>(
126127
}
127128

128129
describe('Store Devtools', () => {
130+
describe('reducer', () => {
131+
it('should call @ngrx/devtools/recompute-state action', () => {
132+
const fixture = createStore(doubleCounter);
133+
counter.calls.reset();
134+
fixture.replaceReducer(counter);
135+
136+
const allArgs = counter.calls.allArgs();
137+
expect(allArgs.length).toEqual(3);
138+
expect(allArgs[0][1].type).toEqual(UPDATE);
139+
expect(allArgs[1][1].type).toEqual(RECOMPUTE_STATE);
140+
expect(allArgs[2][1].type).toEqual(RECOMPUTE_STATE);
141+
});
142+
});
143+
129144
describe('Instrumentation', () => {
130145
let fixture: Fixture<number>;
131146
let store: Store<number>;

modules/store-devtools/src/reducer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export type Actions = DevtoolsActions.All | CoreActions;
2525

2626
export const INIT_ACTION = { type: INIT };
2727

28+
export const RECOMPUTE_STATE = '@ngrx/devtools/recompute-state' as '@ngrx/devtools/recompute-state';
29+
export const RECOMPUTE_STATE_ACTION = { type: RECOMPUTE_STATE };
30+
2831
export interface ComputedState {
2932
state: any;
3033
error: any;
@@ -501,7 +504,7 @@ export function liftReducerWith(
501504
// Recompute state history with latest reducer and update action
502505
computedStates = computedStates.map(cmp => ({
503506
...cmp,
504-
state: reducer(cmp.state, liftedAction),
507+
state: reducer(cmp.state, RECOMPUTE_STATE_ACTION),
505508
}));
506509

507510
currentStateIndex = stagedActionIds.length - 1;

0 commit comments

Comments
 (0)