Rxjava: Request: Add operator to cache only onSuccess value from Single

Created on 2 Mar 2018  路  7Comments  路  Source: ReactiveX/RxJava

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).

2.x Feature-Request

Most helpful comment

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.

All 7 comments

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.

I was asked to publish this operator somewhere. @akarnokd would it be a worthwhile addition to RxJava2Extensions? I believe this use case is actually a pretty common on Android.

Publish it in your own library.

This sounds exactly like what I'm currently looking for. @technoir42 it looks like your gist got deleted? :(

@halfhp I've updated the link in the description.

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.

Can you explain why _you are not conviced_?
Rx offers operators for pretty much everything, why exclude this one? There are definitely use-cases for it...

This operator would be very useful!

Was this page helpful?
0 / 5 - 0 ratings