JakeWharton / RxReplayingShare

An RxJava transformer which combines replay(1), publish(), and refCount() operators.
Apache License 2.0
626 stars 28 forks source link

Only unsubscribe from source after no subscribers + time delay conditions are met #21

Closed ZakTaccardi closed 7 years ago

ZakTaccardi commented 7 years ago

Would this fit within the scope of this library?

Example usage: source.replayingShare(1, TimeUnit.SECONDS)

The above source would only be unsubscribed from after both the following conditions are met

I could imagine this would be pretty useful for caching values such as disk loads across configuration changes.

JakeWharton commented 7 years ago

I don't have a strong opinion. I don't need this and therefore i'm not really interested in implementing it. Do you have an implementation in mind? Is a standalone delayUnsubscription(long, TimeUnit) operator worthwhile which would eliminate the need for it to be built into this library?

hannesstruss commented 7 years ago

delayUnsubscription(long, TimeUnit) does indeed sound like a useful thing to have.

JakeWharton commented 7 years ago

That is something that should be proposed to RxJava, or built as a standalone operator that can be composed with this one. I don't want to massively increase the complexity of this library with timers and scheduling for a use case that I don't have, but also for one which seems more generally applicable for standard operators like share().