Package rx.internal.util
Class ScalarSynchronousObservable<T>
java.lang.Object
rx.Observable<T>
rx.internal.util.ScalarSynchronousObservable<T>
- Type Parameters:
T
- the value type
An Observable that emits a single constant scalar value to Subscribers.
This is a direct implementation of the Observable class to allow identifying it in flatMap and bypass the subscription to it altogether.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
The OnSubscribe callback for the Observable constructor.(package private) static final class
The OnSubscribe implementation that creates the ScalarAsyncProducer for each incoming subscriber.(package private) static final class
Represents a producer which schedules the emission of a scalar value on the first positive request via the given scheduler callback.(package private) static final class
This is the weak version of SingleProducer that uses plain fields to avoid reentrancy and as such is not threadsafe for concurrent request() calls.Nested classes/interfaces inherited from class rx.Observable
Observable.OnSubscribe<T>, Observable.Operator<R,
T>, Observable.Transformer<T, R> -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final boolean
Indicates that the Producer used by this Observable should be fully threadsafe.(package private) final T
The constant scalar value to emit on request. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ScalarSynchronousObservable
<T> create
(T t) Constructs a ScalarSynchronousObservable with the given constant value.(package private) static <T> Producer
createProducer
(Subscriber<? super T> s, T v) Creates a scalar producer depending on the state of STRONG_MODE.get()
Returns the scalar constant value directly.<R> Observable
<R> scalarFlatMap
(Func1<? super T, ? extends Observable<? extends R>> func) Given this scalar source as input to a flatMap, avoid one step of subscription and subscribes to the single Observable returned by the function.scalarScheduleOn
(Scheduler scheduler) Customized observeOn/subscribeOn implementation which emits the scalar value directly or with less overhead on the specified scheduler.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
-
t
The constant scalar value to emit on request. -
STRONG_MODE
static final boolean STRONG_MODEIndicates that the Producer used by this Observable should be fully threadsafe. It is possible, but unlikely that multiple concurrent requests will arrive to just().
-
-
Constructor Details
-
ScalarSynchronousObservable
-
-
Method Details
-
createProducer
Creates a scalar producer depending on the state of STRONG_MODE.- Type Parameters:
T
- the type of the scalar value- Parameters:
s
- the target subscriberv
- the value to emit- Returns:
- the created Producer
-
create
Constructs a ScalarSynchronousObservable with the given constant value.- Type Parameters:
T
- the value type- Parameters:
t
- the value to emit when requested- Returns:
- the new Observable
-
get
Returns the scalar constant value directly.- Returns:
- the scalar constant value directly
-
scalarScheduleOn
Customized observeOn/subscribeOn implementation which emits the scalar value directly or with less overhead on the specified scheduler.- Parameters:
scheduler
- the target scheduler- Returns:
- the new observable
-
scalarFlatMap
Given this scalar source as input to a flatMap, avoid one step of subscription and subscribes to the single Observable returned by the function.If the functions returns another scalar, no subscription happens and this inner scalar value will be emitted once requested.
- Type Parameters:
R
- the result type- Parameters:
func
- the mapper function that returns an Observable for the scalar value of this- Returns:
- the new observable
-