Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions modules/store-devtools/spec/store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -126,6 +127,20 @@ function createStore<T>(
}

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<number>;
let store: Store<number>;
Expand Down
5 changes: 4 additions & 1 deletion modules/store-devtools/src/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test case.

}));

currentStateIndex = stagedActionIds.length - 1;
Expand Down