-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Better cache implementation #1541
Comments
Hey, @christianacca! That's some nice looking code. So you know, you can accomplish roughly the same thing with: source.multicast(() => new ReplaySubject()).refCount() When I like that you're thinking about new ways to solve this problem, though. A more complicated problem around |
Hi Ben, Your suggestion - isn't that pretty much describing the implementation of the existing cache operator? Unless I'm missing something That's because as soon as |
Oh, nevermind, I see what you're saying. Basically it's that on an |
It might be worth discussing having the regular Paging @staltz, @robwormald, @trxcllnt, @mattpodwysocki |
OK cool. Note, that the implementation I posted might not be robust. For example, what would be the implications if the next or error handler registered with the |
Right. It probably wouldn't meet up to our performance requirements either. But it works as a solid reference for the concept, and I appreciate it. |
Yep, I agree the proposal makes more sense than the current implementation. |
What are first steps here? E.g.
This is particularly important for us to evaluate Rx 5 as a replacement for 4. |
If cache is changed in this way, could we also get a version that's implemented like @Blesh's code above? It seems to me that those are the two most common use cases: "cache this thing" and "cache this thing until the subscriptions have ended." |
+1 I used this strategy back in Angular1's |
Looks like this is the discussion on
|
It seems that it's possible to reuse multicast() but still have the feature where the subject is thrown away when there's an error:
|
|
This issue is reopening issue #839.
As it stands the implementation for caching does not satisfy the common use case.
Quoting @Blesh:
I have tried coming up with a basic implementation myself that I think satisfies the above:
Note on above:
safeCache
more to avoid overwriting the existingcache
operator rather than to denote behaviourinvalidateWhen
parameter typed to be an observable but got quickly out of my depth!Now I don't suppose the above implementation is sufficiently robust, even after refactoring, it's more of a way to stimulate more conversation on getting a better implementation.
The text was updated successfully, but these errors were encountered: