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

Bug with .share operator? #1489

Open
jaidetree opened this issue Jun 16, 2017 · 0 comments
Open

Bug with .share operator? #1489

jaidetree opened this issue Jun 16, 2017 · 0 comments

Comments

@jaidetree
Copy link

jaidetree commented Jun 16, 2017

If you have code like this, and you can imagine several of these streams\subscriptions are created throughout the lifecycle of an application. An error is thrown when trying to dispose of all the streams raising an "Object has been disposed" error.

I've attempted to boil it down to the simplest repro case:

let source = Rx.Observable.interval(200)
  .debounce(150)
  .finally(() => console.log('killing source'))
  .take(50)
  .publish();

let subject = new Rx.Subject();

let sourceB = Rx.Observable.interval(500)
  .map(x => x * 100)
  .take(25)
  .subscribe(subject);

let subscriberA = source
  .finally(() => console.log('killing a'))
  .subscribe(x => console.log('A', x));

let subscriberB = source
  .merge(subject)
  .map(x => String.fromCharCode(x + 32))
  .finally(() => console.log('killing b'))
  .subscribe(x => console.log('B', x))

let connection = source.connect();

Rx.Observable
  .timer(5000)
  .subscribe(() => {
    connection.dispose();
    subject.dispose();
  })

Is running from here: https://codepen.io/jayzawrotny/pen/JJbxgE?editors=0011

I would expect that the source gets killed, a & b get killed and then no more data is requested from the subject which will be disposed at that time as well.

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