Skip to content

Instantly share code, notes, and snippets.

@zbarbuto
Last active March 16, 2019 09:07
Show Gist options
  • Save zbarbuto/2d934308f35da310e247ddd5f7afa6ef to your computer and use it in GitHub Desktop.
Save zbarbuto/2d934308f35da310e247ddd5f7afa6ef to your computer and use it in GitHub Desktop.
import { ReduxDevtoolsExtension, ReduxDevtoolsExtensionConnection } from '@ngrx/store-devtools/src/extension';
import { RemoteDevToolsConnectionProxy } from './remote-devtools-connection-proxy'
import { connect } from 'remotedev/lib/devTools';
export class RemoteDevToolsProxy implements ReduxDevtoolsExtension {
remotedev: any = null;
defaultOptions = {
realtime: true,
// Needs to match what you run `remotedev` command with and
// what you setup in remote devtools local connection settings
hostname: 'your.machine.ip.here',
port: 8000,
autoReconnect: true,
connectTimeout: 20000,
ackTimeout: 10000,
secure: true
};
constructor(defaultOptions: Object) {
this.defaultOptions = Object.assign(this.defaultOptions, defaultOptions);
}
connect(options: {
shouldStringify?: boolean;
instanceId: string;
}): ReduxDevtoolsExtensionConnection {
const connectOptions = Object.assign(this.defaultOptions, options);
this.remotedev = connect(connectOptions);
const connectionProxy = new RemoteDevToolsConnectionProxy(
this.remotedev,
connectOptions.instanceId
);
return connectionProxy;
}
send(
action: any,
state: any,
shouldStringify?: boolean,
instanceId?: string
): any {
this.remotedev.send(action, state);
}
}
@yuankunluo
Copy link

hi, in
ReduxDevtoolsExtension the conect method is defined as:
connect(options: ReduxDevtoolsExtensionConfig): ReduxDevtoolsExtensionConnection;

But in your Proxy code, the connect is

connect(options: { shouldStringify?: boolean; instanceId: string; }): ReduxDevtoolsExtensionConnection {

the options as parameter is incamptible with ReduxDevtoolsExtensionConfig:

export interface ReduxDevtoolsExtensionConfig { features?: object | boolean; name: string | undefined; maxAge?: number; serialize?: boolean | SerializationOptions; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment