Package rx.internal.operators
Class CachedObservable<T>
java.lang.Object
rx.Observable<T>
rx.internal.operators.CachedObservable<T>
- Type Parameters:
T
- the source element type
An observable which auto-connects to another observable, caches the elements
from that observable but allows terminating the connection and completing the cache.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
Manages the subscription of child subscribers by setting up a replay producer and performs auto-connection of the very first subscription.(package private) static final class
Contains the active child producers and the values to replay.(package private) static final class
Keeps track of the current request amount and the replay position for a child Subscriber.Nested classes/interfaces inherited from class rx.Observable
Observable.OnSubscribe<T>, Observable.Operator<R,
T>, Observable.Transformer<T, R> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CachedObservable.CacheState
<T> The cache and replay state. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
CachedObservable
(Observable.OnSubscribe<T> onSubscribe, CachedObservable.CacheState<T> state) Private constructor because state needs to be shared between the Observable body and the onSubscribe function. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CachedObservable
<T> from
(Observable<? extends T> source) Creates a cached Observable with a default capacity hint of 16.static <T> CachedObservable
<T> from
(Observable<? extends T> source, int capacityHint) Creates a cached Observable with the given capacity hint.(package private) boolean
Returns true if there are observers subscribed to this observable.(package private) boolean
Check if this cached observable is connected to its source.Methods inherited from class rx.Observable
all, amb, amb, amb, amb, amb, amb, amb, amb, amb, ambWith, asObservable, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, cache, cache, cacheWithInitialCapacity, cast, collect, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatestDelayError, compose, concat, concat, concat, concat, concat, concat, concat, concat, concat, concatDelayError, concatDelayError, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatMap, concatMapDelayError, concatMapEager, concatMapEager, concatMapEager, concatMapIterable, concatWith, contains, count, countLong, create, create, create, debounce, debounce, debounce, defaultIfEmpty, defer, delay, delay, delay, delay, delaySubscription, delaySubscription, delaySubscription, delaySubscription, dematerialize, distinct, distinct, distinctUntilChanged, distinctUntilChanged, distinctUntilChanged, doAfterTerminate, doOnCompleted, doOnEach, doOnEach, doOnError, doOnNext, doOnRequest, doOnSubscribe, doOnTerminate, doOnUnsubscribe, elementAt, elementAtOrDefault, empty, error, exists, extend, filter, finallyDo, first, first, firstOrDefault, firstOrDefault, flatMap, flatMap, flatMap, flatMap, flatMap, flatMap, flatMapIterable, flatMapIterable, flatMapIterable, flatMapIterable, forEach, forEach, forEach, from, from, from, from, from, fromAsync, fromCallable, groupBy, groupBy, groupBy, groupJoin, ignoreElements, interval, interval, interval, interval, isEmpty, join, just, just, just, just, just, just, just, just, just, just, last, last, lastOrDefault, lastOrDefault, lift, limit, map, materialize, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeWith, nest, never, observeOn, observeOn, observeOn, observeOn, ofType, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureDrop, onBackpressureDrop, onBackpressureLatest, onErrorResumeNext, onErrorResumeNext, onErrorReturn, onExceptionResumeNext, onTerminateDetach, publish, publish, range, range, rebatchRequests, reduce, reduce, repeat, repeat, repeat, repeat, repeatWhen, repeatWhen, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, retry, retry, retry, retryWhen, retryWhen, sample, sample, sample, scan, scan, sequenceEqual, sequenceEqual, serialize, share, single, single, singleOrDefault, singleOrDefault, skip, skip, skip, skipLast, skipLast, skipLast, skipUntil, skipWhile, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, switchIfEmpty, switchMap, switchMapDelayError, switchOnNext, switchOnNextDelayError, take, take, take, takeFirst, takeLast, takeLast, takeLast, takeLast, takeLast, takeLastBuffer, takeLastBuffer, takeLastBuffer, takeLastBuffer, takeLastBuffer, takeUntil, takeUntil, takeWhile, throttleFirst, throttleFirst, throttleLast, throttleLast, throttleWithTimeout, throttleWithTimeout, timeInterval, timeInterval, timeout, timeout, timeout, timeout, timeout, timeout, timeout, timeout, timer, timer, timer, timer, timestamp, timestamp, toBlocking, toCompletable, toList, toMap, toMap, toMap, toMultimap, toMultimap, toMultimap, toMultimap, toSingle, toSortedList, toSortedList, toSortedList, toSortedList, unsafeSubscribe, unsubscribeOn, using, using, window, window, window, window, window, window, window, window, window, window, window, window, withLatestFrom, withLatestFrom, withLatestFrom, withLatestFrom, withLatestFrom, withLatestFrom, withLatestFrom, withLatestFrom, withLatestFrom, withLatestFrom, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipWith, zipWith
-
Field Details
-
state
The cache and replay state.
-
-
Constructor Details
-
CachedObservable
private CachedObservable(Observable.OnSubscribe<T> onSubscribe, CachedObservable.CacheState<T> state) Private constructor because state needs to be shared between the Observable body and the onSubscribe function.- Parameters:
onSubscribe
-state
-
-
-
Method Details
-
from
Creates a cached Observable with a default capacity hint of 16.- Type Parameters:
T
- the value type- Parameters:
source
- the source Observable to cache- Returns:
- the CachedObservable instance
-
from
Creates a cached Observable with the given capacity hint.- Type Parameters:
T
- the value type- Parameters:
source
- the source Observable to cachecapacityHint
- the hint for the internal buffer size- Returns:
- the CachedObservable instance
-
isConnected
boolean isConnected()Check if this cached observable is connected to its source.- Returns:
- true if already connected
-
hasObservers
boolean hasObservers()Returns true if there are observers subscribed to this observable.- Returns:
-