Package rx.internal.util
Class ScalarSynchronousObservable<T>
- java.lang.Object
-
- rx.Observable<T>
-
- rx.internal.util.ScalarSynchronousObservable<T>
-
- Type Parameters:
T
- the value type
public final class ScalarSynchronousObservable<T> extends Observable<T>
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 Classes Modifier and Type Class Description (package private) static class
ScalarSynchronousObservable.JustOnSubscribe<T>
The OnSubscribe callback for the Observable constructor.(package private) static class
ScalarSynchronousObservable.ScalarAsyncOnSubscribe<T>
The OnSubscribe implementation that creates the ScalarAsyncProducer for each incoming subscriber.(package private) static class
ScalarSynchronousObservable.ScalarAsyncProducer<T>
Represents a producer which schedules the emission of a scalar value on the first positive request via the given scheduler callback.(package private) static class
ScalarSynchronousObservable.WeakSingleProducer<T>
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
Fields Modifier and Type Field Description (package private) static boolean
STRONG_MODE
Indicates that the Producer used by this Observable should be fully threadsafe.(package private) T
t
The constant scalar value to emit on request.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ScalarSynchronousObservable(T t)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <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.T
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.Observable<T>
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 Detail
-
t
final T t
The constant scalar value to emit on request.
-
STRONG_MODE
static final boolean STRONG_MODE
Indicates 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 Detail
-
ScalarSynchronousObservable
protected ScalarSynchronousObservable(T t)
-
-
Method Detail
-
createProducer
static <T> Producer createProducer(Subscriber<? super T> s, T v)
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
public static <T> ScalarSynchronousObservable<T> create(T t)
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
public T get()
Returns the scalar constant value directly.- Returns:
- the scalar constant value directly
-
scalarScheduleOn
public Observable<T> scalarScheduleOn(Scheduler scheduler)
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
public <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.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
-
-