store-devtools
store-devtools copied to clipboard
createChangesObservable() immediately unsubscribes instead of returning a wrapper Fn
I'm using store-devtools with remotedev for on-device debugging as described in https://gist.github.com/rob3c/c2c4dcc1116f94901ace179722c5f6d4 and I'm trying to get state updates from the inspector working. Time travel and state imports are both addressed in separate issues, but I don't see this particular detail addressed yet in the current master:
It looks like the createChangesObservable()
function in extension.ts
mistakenly calls connection.unsubscribe()
immediately when wrapping the extension in an Observable, rather than returning a function that calls it as a dispose/unsubscribe function for the subscriber to call later. This immediately cancels the subscription, so server updates are never received.
Here's the current code:
private createChangesObservable(): Observable<any> {
if (!this.devtoolsExtension) {
return empty();
}
return new Observable(subscriber => {
const connection = this.devtoolsExtension.connect({ instanceId: this.instanceId });
connection.subscribe(change => subscriber.next(change));
return connection.unsubscribe();
});
}
That last line should probably be something like this:
return () => connection.unsubscribe();
It was only working coincidentally due to a bug in remotedev's unsubscribe code, but that's been fixed in 2.0.3 (See https://github.com/zalmoxisus/remotedev/issues/4).