Skip to content

Commit

Permalink
feat(StoreDevtools): Pass stateSanitizer as argument instead
Browse files Browse the repository at this point in the history
  • Loading branch information
kgkma committed Feb 12, 2018
1 parent c54d8bf commit c6d6110
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 1 addition & 5 deletions modules/store-devtools/spec/extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { Action } from '@ngrx/store';
import { of } from 'rxjs/observable/of';

import { LiftedState } from '../';
import {
DevtoolsExtension,
ReduxDevtoolsExtension,
ReduxDevtoolsExtensionConnection,
} from '../src/extension';
import { DevtoolsExtension, ReduxDevtoolsExtension } from '../src/extension';
import { createConfig, noMonitor } from '../src/instrument';

describe('DevtoolsExtension', () => {
Expand Down
2 changes: 1 addition & 1 deletion modules/store-devtools/spec/store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ describe('Store Devtools', () => {
const liftedState = fixture.getLiftedState();
const sanitizedLiftedState = fixture.devtools.getSanitizedState(
liftedState,
devtoolsOptions
devtoolsOptions.stateSanitizer
);
const originalAction =
liftedState.actionsById[liftedState.nextActionId - 1];
Expand Down
12 changes: 8 additions & 4 deletions modules/store-devtools/src/devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ import {
ComputedState,
} from './reducer';
import * as Actions from './actions';
import { StoreDevtoolsConfig, STORE_DEVTOOLS_CONFIG } from './config';
import {
StoreDevtoolsConfig,
STORE_DEVTOOLS_CONFIG,
StateSanitizer,
} from './config';

@Injectable()
export class DevtoolsDispatcher extends ActionsSubject {}
Expand Down Expand Up @@ -78,7 +82,7 @@ export class StoreDevtools implements Observer<any> {
// Extension should be sent the sanitized lifted state
extension.notify(
action,
this.getSanitizedState(reducedLiftedState, config)
this.getSanitizedState(reducedLiftedState, config.stateSanitizer)
);

return { state: reducedLiftedState, action };
Expand Down Expand Up @@ -110,8 +114,8 @@ export class StoreDevtools implements Observer<any> {
* Restructures the lifted state passed in to prepare for sending to the
* Redux Devtools Extension
*/
getSanitizedState(state: LiftedState, config: Partial<StoreDevtoolsConfig>) {
const sanitizedComputedStates = config.stateSanitizer
getSanitizedState(state: LiftedState, stateSanitizer?: StateSanitizer) {
const sanitizedComputedStates = stateSanitizer
? state.computedStates.map((entry: ComputedState) => ({
state: entry.sanitizedState,
error: entry.error,
Expand Down

0 comments on commit c6d6110

Please sign in to comment.