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

'cache()' should allow subscribe after unsubscribe #2010

Closed
alex-novikov-1990 opened this issue Oct 6, 2016 · 4 comments
Closed

'cache()' should allow subscribe after unsubscribe #2010

alex-novikov-1990 opened this issue Oct 6, 2016 · 4 comments

Comments

@alex-novikov-1990
Copy link

alex-novikov-1990 commented Oct 6, 2016

RxJS version: Latest
Code to reproduce:

var cached = Observable.timer(200).cache();
var subscription = cached.subscribe(v => console.log(v));
setTimeout(() => {
    subscription.unsubscribe();
    cached.subscribe(v => console.log(v));
}, 100);

Expected behavior:
"0" in console.
Actual behavior:
Nothing in console.
Additional information:
Subject should be nulled on outerSub unsubscribtion
https://github.com/ReactiveX/rxjs/blob/master/src/operator/cache.ts#L55

@benlesh
Copy link
Member

benlesh commented Oct 6, 2016

... and here's another issue that leads me to believe cache should be removed from v5 until we more specifically bikeshed it's behavior.

@alex-novikov-1990
Copy link
Author

Oh, it's probably a dupe of #1959
Use case from my project (serviceCall is angular 2 http.post with retry logic):

cache.observable = serviceCall
    .expand(() => Observable.timer(period).concatMap(() => serviceCall))
    .cache(1, period);

@jayphelps
Copy link
Member

jayphelps commented Oct 12, 2016

@newsash we ended up removing the .cache() operator for RC1 because in it's current state it was too confusing and [poorly] trying to solve too many problems.

We do plan to revisit in the future and possibly provide one or more operators that have differing forms of caching.

Everyone has differing opinions and use cases for what "caching" should mean and it's far more complex that it may seem at first. Some additional thoughts can be found here.

@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
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

3 participants