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 Aug 8, 2018
1 parent 29fd07e commit 980d05b
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 @@ -148,8 +146,7 @@ describe('DevtoolsExtension', () => {
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith(
null,
state,
defaultOptions,
'ngrx-store-1509655064369'
defaultOptions
);
});

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

Expand Down Expand Up @@ -230,8 +226,7 @@ describe('DevtoolsExtension', () => {
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith(
null,
state,
options,
'ngrx-store-1509655064369'
options
);
});
});
Expand Down Expand Up @@ -276,8 +271,7 @@ describe('DevtoolsExtension', () => {
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith(
null,
sanitizedState,
options,
'ngrx-store-1509655064369'
options
);
});
});
Expand Down Expand Up @@ -320,8 +314,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 @@ -39,7 +39,6 @@ export interface ReduxDevtoolsExtensionConnection {
export interface ReduxDevtoolsExtensionConfig {
features?: object | boolean;
name: string | undefined;
instanceId: string;
maxAge?: number;
serialize?: boolean | SerializationOptions;
}
Expand All @@ -48,17 +47,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 @@ -123,8 +116,7 @@ export class DevtoolsExtension {
this.devtoolsExtension.send(
null,
sanitizedLiftedState,
this.getExtensionConfig(this.instanceId, this.config),
this.instanceId
this.getExtensionConfig(this.config)
);
}
}
Expand All @@ -136,7 +128,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 @@ -147,7 +139,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 @@ -185,9 +177,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 980d05b

Please sign in to comment.