Skip to content

Commit

Permalink
ngrx#853 removed instanceId generation to add support for persist
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Apr 3, 2018
1 parent 609da88 commit f44fa80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
17 changes: 5 additions & 12 deletions modules/store-devtools/spec/extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function createOptions(
maxAge: false | number = false
) {
const options: ReduxDevtoolsExtensionConfig = {
instanceId: 'ngrx-store-1509655064369',
name,
features,
serialize,
Expand Down Expand Up @@ -70,7 +69,6 @@ describe('DevtoolsExtension', () => {
(reduxDevtoolsExtension.connect as jasmine.Spy).and.returnValue(
extensionConnection
);
spyOn(Date, 'now').and.returnValue('1509655064369');
});

function myActionSanitizer(action: Action, idx: number) {
Expand Down Expand Up @@ -129,8 +127,7 @@ describe('DevtoolsExtension', () => {
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith(
null,
state,
defaultOptions,
'ngrx-store-1509655064369'
defaultOptions
);
});

Expand Down Expand Up @@ -159,8 +156,7 @@ describe('DevtoolsExtension', () => {
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith(
null,
state,
options,
'ngrx-store-1509655064369'
options
);
});

Expand Down Expand Up @@ -211,8 +207,7 @@ describe('DevtoolsExtension', () => {
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith(
null,
state,
options,
'ngrx-store-1509655064369'
options
);
});
});
Expand Down Expand Up @@ -257,8 +252,7 @@ describe('DevtoolsExtension', () => {
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith(
null,
sanitizedState,
options,
'ngrx-store-1509655064369'
options
);
});
});
Expand Down Expand Up @@ -301,8 +295,7 @@ describe('DevtoolsExtension', () => {
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith(
null,
sanitizedState,
options,
'ngrx-store-1509655064369'
options
);
});
});
Expand Down
19 changes: 5 additions & 14 deletions modules/store-devtools/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export interface ReduxDevtoolsExtensionConnection {
export interface ReduxDevtoolsExtensionConfig {
features?: object | boolean;
name: string | undefined;
instanceId: string;
maxAge?: number;
serialize?: boolean;
}
Expand All @@ -44,17 +43,11 @@ export interface ReduxDevtoolsExtension {
connect(
options: ReduxDevtoolsExtensionConfig
): ReduxDevtoolsExtensionConnection;
send(
action: any,
state: any,
options: ReduxDevtoolsExtensionConfig,
instanceId?: string
): void;
send(action: any, state: any, options: ReduxDevtoolsExtensionConfig): void;
}

@Injectable()
export class DevtoolsExtension {
private instanceId = `ngrx-store-${Date.now()}`;
private devtoolsExtension: ReduxDevtoolsExtension;
private extensionConnection: ReduxDevtoolsExtensionConnection;

Expand Down Expand Up @@ -118,8 +111,7 @@ export class DevtoolsExtension {
this.devtoolsExtension.send(
null,
sanitizedLiftedState,
this.getExtensionConfig(this.instanceId, this.config),
this.instanceId
this.getExtensionConfig(this.config)
);
}
}
Expand All @@ -131,7 +123,7 @@ export class DevtoolsExtension {

return new Observable(subscriber => {
const connection = this.devtoolsExtension.connect(
this.getExtensionConfig(this.instanceId, this.config)
this.getExtensionConfig(this.config)
);
this.extensionConnection = connection;
connection.init();
Expand All @@ -142,7 +134,7 @@ export class DevtoolsExtension {
}

private createActionStreams() {
// Listens to all changes based on our instanceId
// Listens to all changes
const changes$ = this.createChangesObservable().pipe(share());

// Listen for the start action
Expand Down Expand Up @@ -179,9 +171,8 @@ export class DevtoolsExtension {
return typeof action === 'string' ? eval(`(${action})`) : action;
}

private getExtensionConfig(instanceId: string, config: StoreDevtoolsConfig) {
private getExtensionConfig(config: StoreDevtoolsConfig) {
const extensionOptions: ReduxDevtoolsExtensionConfig = {
instanceId: instanceId,
name: config.name,
features: config.features,
serialize: config.serialize,
Expand Down

0 comments on commit f44fa80

Please sign in to comment.