Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

createChangesObservable() immediately unsubscribes instead of returning a wrapper Fn #35

Open
rob3c opened this issue Oct 28, 2016 · 0 comments

Comments

@rob3c
Copy link

rob3c commented Oct 28, 2016

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 zalmoxisus/remotedev#4).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant