Skip to content

Commit

Permalink
adding support for name in storedevtools ngrx#463
Browse files Browse the repository at this point in the history
  • Loading branch information
rupeshtiwari committed Oct 21, 2017
1 parent 3b6da60 commit e0b05f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
17 changes: 3 additions & 14 deletions modules/store-devtools/spec/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,9 @@ import { ActionReducer, Action } from '@ngrx/store';
import { StoreDevtoolsConfig } from '../';

describe('StoreDevtoolsOptions', () => {
it('can be initialized with actionSanitizer', () => {
it('can be initialized with name', () => {
const options = new StoreDevtoolsConfig();
function sanitizer(action: Action, id: number): Action {
return action;
}
options.actionSanitizer = sanitizer;
expect(options.actionSanitizer).toEqual(sanitizer);
});
it('can be initialized with stateSanitizer', () => {
const options = new StoreDevtoolsConfig();
function stateSanitizer(state: any, index: number): any {
return state;
}
options.actionSanitizer = stateSanitizer;
expect(options.actionSanitizer).toEqual(stateSanitizer);
options.name = 'my instance';
expect(options.name).toBe('my instance');
});
});
3 changes: 1 addition & 2 deletions modules/store-devtools/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { InjectionToken, Type } from '@angular/core';
export class StoreDevtoolsConfig {
maxAge: number | false;
monitor: ActionReducer<any, any>;
actionSanitizer?: <A extends Action>(action: A, id: number) => A;
stateSanitizer?: <S>(state: S, index: number) => S;
name: string;
}

export const STORE_DEVTOOLS_CONFIG = new InjectionToken<StoreDevtoolsConfig>(
Expand Down
11 changes: 2 additions & 9 deletions modules/store-devtools/src/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,15 @@ export function noMonitor(): null {
return null;
}

export function noActionSanitizer(): null {
return null;
}

export function noStateSanitizer(): null {
return null;
}
export const DEFAULT_NAME = 'store-devtool-instance';

export function createConfig(
_options: StoreDevtoolsOptions
): StoreDevtoolsConfig {
const DEFAULT_OPTIONS: StoreDevtoolsConfig = {
maxAge: false,
monitor: noMonitor,
actionSanitizer: noActionSanitizer,
stateSanitizer: noStateSanitizer,
name: DEFAULT_NAME,
};

let options = typeof _options === 'function' ? _options() : _options;
Expand Down

0 comments on commit e0b05f4

Please sign in to comment.