T
- the cached value typepublic final class OnSubscribeCache<T> extends java.lang.Object implements Observable.OnSubscribe<T>
Observable.replay()
except that this auto-subscribes
to the source Observable rather than returning a connectable Observable.
This is useful with an Observable that you want to cache responses when you can't control the subscribe/unsubscribe behavior of all the Observers.
Note: You sacrifice the ability to unsubscribe from the origin when you use this operator, so be careful not to use this operator on Observables that emit infinite or very large numbers of items, as this will use up memory.
Modifier and Type | Field and Description |
---|---|
protected Subject<? super T,? extends T> |
cache |
protected Observable<? extends T> |
source |
Constructor and Description |
---|
OnSubscribeCache(Observable<? extends T> source) |
OnSubscribeCache(Observable<? extends T> source,
int capacity) |
Modifier and Type | Method and Description |
---|---|
void |
call(Subscriber<? super T> s) |
protected final Observable<? extends T> source
public OnSubscribeCache(Observable<? extends T> source)
public OnSubscribeCache(Observable<? extends T> source, int capacity)
public void call(Subscriber<? super T> s)
call
in interface Action1<Subscriber<? super T>>