These are chat archives for ReactiveX/RxJava

25th
Aug 2015
Samuel Tardieu
@samueltardieu
Aug 25 2015 08:37
Hi. Is there an equivalent to delaySubscription but for unsubscription? I'd like to be able to have the subscriber be effectively unsubscribed, but the observable should not be unsubscribed immediately (and sent data should be sent to oblivion). Use case: a GPS observable that takes time to acquire a fix initially that is share()d. A delayed unsubscription would let the GPS active for a few seconds in case another subscriber gets interested fast enough. I guess that could be a variant of refCount() too, that would take a delay before unsubscribing.
Samuel Tardieu
@samueltardieu
Aug 25 2015 14:41
(I cooked up an operator for doing this if anyone is interested: https://gist.github.com/samueltardieu/12db44dc01340f22e9da)
Dave Moten
@davidmoten
Aug 25 2015 19:14
@samueltardieu I had a look, don't you want the scheduled unsubscribe to be cancelled on a new subscription as well?
Samuel Tardieu
@samueltardieu
Aug 25 2015 22:32
@davidmoten It doesn't matter if this occurs after a refCount(), since it won't unsubscribe if a new subscription has arrived in the meantime as the subscriber count will not go down to zero.
(I can use it as newObservable = observable.share().lift(new DelayedUnsubscription(5, TimeUnit.SECONDS)), and I then subscribe to newObservable)
Abhinav Solan
@eyeced
Aug 25 2015 23:12
n