Request: Add operator to cache only onSuccess value from Single
See original GitHub issueBasically like Single#cache
but that would re-subscribe to source if it previously terminated with onError
.
Use case: caching network responses in memory. Single#cache
is not suitable for this purpose because we generally don’t want to cache network errors but instead retry the request on subsequent subscriptions.
This is what we currently use https://gist.github.com/technoir42/93cf3647aa869dde498b0afe663c83ea (based upon Single#cache
).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:7 (2 by maintainers)
Top Results From Across the Web
rx java - Is there a way to cache the result of a Single or avoid ...
First, checking user existence runs when you will call getUser method ... If you are using Single.cache, you can drop the caching logic...
Read more >Single (RxJava Javadoc 3.1.5) - ReactiveX
Calls the shared consumer with the error sent via onError or the value via onSuccess for each SingleObserver that subscribes to the current...
Read more >Queries - Apollo GraphQL Docs
This article shows how to fetch GraphQL data in React with the useQuery hook and attach the result to your UI. You'll also...
Read more >Cache HTTP requests with RxJS for Angular - Medium
This is what I did in that first version. The two methods use the HttpClient to send GET requests to the backend. I...
Read more >Asynchronous Flow - Kotlin
A suspending function asynchronously returns a single value, but how can we return ... These operators are cold, just like flows are. A...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Such behavior seems to be peculiar to your use case and you did a good job implementing a solution for it locally. I’m not convinced the operator should be added to RxJava though.
Publish it in your own library.