Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share operator does not reconnect to source observable when rxjs spy is running #37

Closed
jpmitche11 opened this issue Aug 22, 2018 · 4 comments
Labels

Comments

@jpmitche11
Copy link

jpmitche11 commented Aug 22, 2018

Rxjs-spy is not handling connectable observables correctly. This will impact the multicast family of operators, including share.

When a shared observable is completely unsubscribed, then resubscribed later, normally the source observable is resubscribed.
When there is a spy object created, this is not working. The share operator creates an internal subject, I see that is not being unsubscribed as well.

Here is some code that demonstrates the issue. The issue is present if a spy object has been created.

const shared$ = interval(100).pipe(
  share()
);

const a = shared.subscribe(() => log('a'))
setTimeout(() => a.unsubscribe(), 200);  // a logged twice, then the interval() observable is unsubscribed

setTimeout(() => shared.subscribe(() => log('b')),  1000);    //Nothing logged. This should log b repeatedly

Here is a runnable version
https://stackblitz.com/edit/rxjs-spy-share?file=index.ts

@cartant
Copy link
Owner

cartant commented Aug 22, 2018

Thanks. I really appreciate the StackBlitz reproduction.

@cartant cartant added the bug label Aug 22, 2018
@cartant
Copy link
Owner

cartant commented Aug 22, 2018

Until I find and fix the problem, there is an alternate workaround. You can hide the shared observable from the spy, like this:

import { hide } from "rxjs-spy/operators";
const shared$ = interval(100).pipe(
  share(),
  hide()
);

cartant added a commit that referenced this issue Aug 22, 2018
@jpmitche11
Copy link
Author

Confirmed hide operator works around the issue. Thanks.

@cartant
Copy link
Owner

cartant commented Aug 25, 2018

This should be fixed in 7.0.3.

@cartant cartant closed this as completed Aug 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants