public final class Observables extends Object
Modifier and Type | Method and Description |
---|---|
static <T> CachedObservable<T> |
cache(io.reactivex.Observable<T> source)
Returns a cached
Flowable like Flowable.cache()
except that the cache can be reset by calling
CachedFlowable.reset() . |
static <T> io.reactivex.Observable<T> |
cache(io.reactivex.Observable<T> source,
long duration,
TimeUnit unit,
io.reactivex.Scheduler.Worker worker)
Returns a cached
Observable like Observable.cache()
except that the cache can be reset by calling
CachedObservable.reset() and the cache will be automatically
reset an interval after first subscription (or first subscription after
reset). |
static <T> CloseableObservableWithReset<T> |
cache(io.reactivex.Observable<T> source,
long duration,
TimeUnit unit,
io.reactivex.Scheduler scheduler)
Returns a cached
Observable like Observable.cache()
except that the cache may be reset by the user calling
CloseableObservableWithReset.reset() . |
public static <T> CachedObservable<T> cache(io.reactivex.Observable<T> source)
Flowable
like Flowable.cache()
except that the cache can be reset by calling
CachedFlowable.reset()
.T
- the generic type of the sourcesource
- the observable to be cached.public static <T> io.reactivex.Observable<T> cache(io.reactivex.Observable<T> source, long duration, TimeUnit unit, io.reactivex.Scheduler.Worker worker)
Observable
like Observable.cache()
except that the cache can be reset by calling
CachedObservable.reset()
and the cache will be automatically
reset an interval after first subscription (or first subscription after
reset). The interval is defined by duration
and unit
.T
- the generic type of the sourcesource
- the source observableduration
- duration till next resetunit
- units corresponding to the durationworker
- worker to use for scheduling reset. Don't forget to
unsubscribe the worker when no longer required.public static <T> CloseableObservableWithReset<T> cache(io.reactivex.Observable<T> source, long duration, TimeUnit unit, io.reactivex.Scheduler scheduler)
Observable
like Observable.cache()
except that the cache may be reset by the user calling
CloseableObservableWithReset.reset()
.T
- generic type of source observablesource
- the source observableduration
- duration till next resetunit
- units corresponding to the durationscheduler
- scheduler to use for scheduling reset.CloseableObservableWithReset
that should be closed once
finished to prevent worker memory leak.Copyright © 2013–2020. All rights reserved.