question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request: Add operator to cache only onSuccess value from Single

See original GitHub issue

Basically 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:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
akarnokdcommented, Mar 2, 2018

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.

2reactions
akarnokdcommented, Apr 13, 2018

Publish it in your own library.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found