Top Description Inners Fields Constructors Methods
rx.internal.util

public final Class ScalarSynchronousObservable<T>

extends Observable<T>
Class Inheritance
Type Parameters
<T>
the value type
Imports
java.util.concurrent.atomic.AtomicBoolean, rx.*, rx.exceptions.Exceptions, rx.functions.*, rx.internal.producers.SingleProducer, rx.internal.schedulers.EventLoopsScheduler, rx.observers.Subscribers, rx.plugins.*

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 and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ScalarSynchronousObservable.JustOnSubscribe<T>

The OnSubscribe callback for the Observable constructor.

pack-priv static class
ScalarSynchronousObservable.ScalarAsyncOnSubscribe<
the value type
T
>

The OnSubscribe implementation that creates the ScalarAsyncProducer for each incoming subscriber.

pack-priv static class
ScalarSynchronousObservable.ScalarAsyncProducer<
the value type
T
>

Represents a producer which schedules the emission of a scalar value on the first positive request via the given scheduler callback.

pack-priv static class
ScalarSynchronousObservable.WeakSingleProducer<
the value type
T
>

This is the weak version of SingleProducer that uses plain fields to avoid re-entrant invocation and as such is not thread-safe for concurrent request() calls.

Field Summary

Modifier and TypeField and Description
pack-priv static final boolean
STRONG_MODE

Indicates that the Producer used by this Observable should be fully thread-safe.

pack-priv final T
t

The constant scalar value to emit on request.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static <
the value type
T
>
ScalarSynchronousObservable<T>

Returns:

the new Observable
create
(T
the value to emit when requested
t
)

Constructs a ScalarSynchronousObservable with the given constant value.

pack-priv static <
the type of the scalar value
T
>
Producer

Returns:

the created Producer
createProducer
(Subscriber<? super T>
the target subscriber
s
,
T
the value to emit
v
)

Creates a scalar producer depending on the state of STRONG_MODE.

public T

Returns:

the scalar constant value directly
get
()

Returns the scalar constant value directly.

public <
the result type
R
>
Observable<R>

Returns:

the new observable
scalarFlatMap
(final Func1<? super T, ? extends Observable<? extends R>>
the mapper function that returns an Observable for the scalar value of this
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.

public Observable<T>

Returns:

the new observable
scalarScheduleOn
(final Scheduler
the target scheduler
scheduler
)

Customized observeOn/subscribeOn implementation which emits the scalar value directly or with less overhead on the specified scheduler.

Inherited from rx.Observable:
allambambambambambambambambambambWithasObservablebufferbufferbufferbufferbufferbufferbufferbufferbufferbufferbufferbuffercachecachecacheWithInitialCapacitycastcollectcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestDelayErrorcomposeconcatconcatconcatconcatconcatconcatconcatconcatconcatconcatconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatMapconcatMapDelayErrorconcatMapEagerconcatMapEagerconcatMapEagerconcatMapIterableconcatWithcontainscountcountLongcreatecreatecreatecreatedebouncedebouncedebouncedefaultIfEmptydeferdelaydelaydelaydelaydelaySubscriptiondelaySubscriptiondelaySubscriptiondelaySubscriptiondematerializedistinctdistinctdistinctUntilChangeddistinctUntilChangeddistinctUntilChangeddoAfterTerminatedoOnCompleteddoOnEachdoOnEachdoOnErrordoOnNextdoOnRequestdoOnSubscribedoOnTerminatedoOnUnsubscribeelementAtelementAtOrDefaultemptyerrorexistsfilterfinallyDofirstfirstfirstOrDefaultfirstOrDefaultflatMapflatMapflatMapflatMapflatMapflatMapflatMapCompletableflatMapCompletableflatMapCompletableflatMapIterableflatMapIterableflatMapIterableflatMapIterableflatMapSingleflatMapSingleflatMapSingleforEachforEachforEachfromfromfromfromfromfromCallablegroupBygroupBygroupBygroupBygroupJoinignoreElementsintervalintervalintervalintervalisEmptyjoinjustjustjustjustjustjustjustjustjustjustlastlastlastOrDefaultlastOrDefaultliftlimitmapmaterializemergemergemergemergemergemergemergemergemergemergemergemergemergemergemergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeWithnestneverobserveOnobserveOnobserveOnobserveOnofTypeonBackpressureBufferonBackpressureBufferonBackpressureBufferonBackpressureBufferonBackpressureDroponBackpressureDroponBackpressureLatestonErrorResumeNextonErrorResumeNextonErrorReturnonExceptionResumeNextonTerminateDetachpublishpublishrangerangerebatchRequestsreducereducerepeatrepeatrepeatrepeatrepeatWhenrepeatWhenreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayretryretryretryretryWhenretryWhensamplesamplesamplescanscansequenceEqualsequenceEqualserializesharesinglesinglesingleOrDefaultsingleOrDefaultskipskipskipskipLastskipLastskipLastskipUntilskipWhilesortedsortedstartWithstartWithstartWithstartWithstartWithstartWithstartWithstartWithstartWithstartWithstartWithsubscribesubscribesubscribesubscribesubscribesubscribesubscribeOnsubscribeOnswitchIfEmptyswitchMapswitchMapDelayErrorswitchOnNextswitchOnNextDelayErrortaketaketaketakeFirsttakeLasttakeLasttakeLasttakeLasttakeLasttakeLastBuffertakeLastBuffertakeLastBuffertakeLastBuffertakeLastBuffertakeUntiltakeUntiltakeWhiletesttestthrottleFirstthrottleFirstthrottleLastthrottleLastthrottleWithTimeoutthrottleWithTimeouttimeIntervaltimeIntervaltimeouttimeouttimeouttimeouttimeouttimeouttimeouttimeouttimertimertimertimertimestamptimestamptotoBlockingtoCompletabletoListtoMaptoMaptoMaptoMultimaptoMultimaptoMultimaptoMultimaptoSingletoSortedListtoSortedListtoSortedListtoSortedListunsafeCreateunsafeSubscribeunsubscribeOnusingusingwindowwindowwindowwindowwindowwindowwindowwindowwindowwindowwindowwindowwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromzipzipzipzipzipzipzipzipzipzipzipzipWithzipWith

Field Detail

STRONG_MODEback to summary
pack-priv static final boolean STRONG_MODE

Indicates that the Producer used by this Observable should be fully thread-safe. It is possible, but unlikely that multiple concurrent requests will arrive to just().

tback to summary
pack-priv final T t

The constant scalar value to emit on request.

Constructor Detail

ScalarSynchronousObservableback to summary
protected ScalarSynchronousObservable(final T t)

Method Detail

createback to summary
public static <T> ScalarSynchronousObservable<T> create(T t)

Constructs a ScalarSynchronousObservable with the given constant value.

Parameters
<T>
the value type
t:T

the value to emit when requested

Returns:ScalarSynchronousObservable<T>

the new Observable

createProducerback to summary
pack-priv static <T> Producer createProducer(Subscriber<? super T> s, T v)

Creates a scalar producer depending on the state of STRONG_MODE.

Parameters
<T>
the type of the scalar value
s:Subscriber<? super T>

the target subscriber

v:T

the value to emit

Returns:Producer

the created Producer

getback to summary
public T get()

Returns the scalar constant value directly.

Returns:T

the scalar constant value directly

scalarFlatMapback to summary
public <R> Observable<R> scalarFlatMap(final 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.

Parameters
<R>
the result type
func:Func1<? super T, ? extends Observable<? extends R>>

the mapper function that returns an Observable for the scalar value of this

Returns:Observable<R>

the new observable

scalarScheduleOnback to summary
public Observable<T> scalarScheduleOn(final Scheduler scheduler)

Customized observeOn/subscribeOn implementation which emits the scalar value directly or with less overhead on the specified scheduler.

Parameters
scheduler:Scheduler

the target scheduler

Returns:Observable<T>

the new observable

rx.internal.util back to summary

pack-priv final Class ScalarSynchronousObservable.JustOnSubscribe<T>

extends Object
implements Observable.OnSubscribe<T>
Class Inheritance
All Implemented Interfaces
rx.Observable.OnSubscribe, rx.functions.Action1, rx.functions.Action, rx.functions.Function

The OnSubscribe callback for the Observable constructor.

Field Summary

Modifier and TypeField and Description
pack-priv final T

Constructor Summary

AccessConstructor and Description
pack-priv
JustOnSubscribe(T value)

Method Summary

Modifier and TypeMethod and Description
public void
call(Subscriber<? super T> s)

Implements rx.functions.Action1.call.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

valueback to summary
pack-priv final T value

Constructor Detail

JustOnSubscribeback to summary
pack-priv JustOnSubscribe(T value)

Method Detail

callback to summary
public void call(Subscriber<? super T> s)

Implements rx.functions.Action1.call.

Annotations
@Override
rx.internal.util back to summary

pack-priv final Class ScalarSynchronousObservable.ScalarAsyncOnSubscribe<T>

extends Object
implements Observable.OnSubscribe<T>
Class Inheritance
  • java.lang.Object
  • rx.internal.util.ScalarSynchronousObservable.ScalarAsyncOnSubscribe
All Implemented Interfaces
rx.Observable.OnSubscribe, rx.functions.Action1, rx.functions.Action, rx.functions.Function
Type Parameters
<T>
the value type

The OnSubscribe implementation that creates the ScalarAsyncProducer for each incoming subscriber.

Field Summary

Modifier and TypeField and Description
pack-priv final Func1<Action0, Subscription>
pack-priv final T

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
call(Subscriber<? super T> s)

Implements rx.functions.Action1.call.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

onScheduleback to summary
pack-priv final Func1<Action0, Subscription> onSchedule
valueback to summary
pack-priv final T value

Constructor Detail

ScalarAsyncOnSubscribeback to summary
pack-priv ScalarAsyncOnSubscribe(T value, Func1<Action0, Subscription> onSchedule)

Method Detail

callback to summary
public void call(Subscriber<? super T> s)

Implements rx.functions.Action1.call.

Annotations
@Override
rx.internal.util back to summary

pack-priv final Class ScalarSynchronousObservable.ScalarAsyncProducer<T>

extends AtomicBoolean
implements Producer, Action0
Class Inheritance
All Implemented Interfaces
rx.functions.Action0, rx.functions.Action, rx.functions.Function, rx.Producer
Type Parameters
<T>
the value type

Represents a producer which schedules the emission of a scalar value on the first positive request via the given scheduler callback.

Field Summary

Modifier and TypeField and Description
pack-priv final Subscriber<? super T>
pack-priv final Func1<Action0, Subscription>
private static final long
pack-priv final T

Constructor Summary

AccessConstructor and Description
public
ScalarAsyncProducer(Subscriber<? super T> actual, T value, Func1<Action0, Subscription> onSchedule)

Method Summary

Modifier and TypeMethod and Description
public void
public void
request(long
the maximum number of items you want this Producer to produce, or Long.MAX_VALUE if you want the Producer to produce items at its own pace
n
)

Implements rx.Producer.request.

Request a certain maximum number of items from this Producer.
public String
toString()

Overrides java.util.concurrent.atomic.AtomicBoolean.toString.

Returns the String representation of the current value.
Inherited from java.util.concurrent.atomic.AtomicBoolean:
compareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndSetgetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleaseweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

actualback to summary
pack-priv final Subscriber<? super T> actual
onScheduleback to summary
pack-priv final Func1<Action0, Subscription> onSchedule
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicBoolean.serialVersionUID.

valueback to summary
pack-priv final T value

Hides java.util.concurrent.atomic.AtomicBoolean.value.

Constructor Detail

ScalarAsyncProducerback to summary
public ScalarAsyncProducer(Subscriber<? super T> actual, T value, Func1<Action0, Subscription> onSchedule)

Method Detail

callback to summary
public void call()

Implements rx.functions.Action0.call.

Annotations
@Override
requestback to summary
public void request(long n)

Implements rx.Producer.request.

Doc from rx.Producer.request.

Request a certain maximum number of items from this Producer. This is a way of requesting backpressure. To disable backpressure, pass Long.MAX_VALUE to this method.

Requests are additive but if a sequence of requests totals more than Long.MAX_VALUE then Long.MAX_VALUE requests will be actioned and the extras may be ignored. Arriving at Long.MAX_VALUE by addition of requests cannot be assumed to disable backpressure. For example, the code below may result in Long.MAX_VALUE requests being actioned only.

request(100);
request(Long.MAX_VALUE-1);
Parameters
n:long

the maximum number of items you want this Producer to produce, or Long.MAX_VALUE if you want the Producer to produce items at its own pace

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.util.concurrent.atomic.AtomicBoolean.toString.

Doc from java.util.concurrent.atomic.AtomicBoolean.toString.

Returns the String representation of the current value.

Returns:String

the String representation of the current value

Annotations
@Override
rx.internal.util back to summary

pack-priv final Class ScalarSynchronousObservable.WeakSingleProducer<T>

extends Object
implements Producer
Class Inheritance
  • java.lang.Object
  • rx.internal.util.ScalarSynchronousObservable.WeakSingleProducer
All Implemented Interfaces
rx.Producer
Type Parameters
<T>
the value type

This is the weak version of SingleProducer that uses plain fields to avoid re-entrant invocation and as such is not thread-safe for concurrent request() calls.

Field Summary

Modifier and TypeField and Description
pack-priv final Subscriber<? super T>
pack-priv boolean
pack-priv final T

Constructor Summary

AccessConstructor and Description
public
WeakSingleProducer(Subscriber<? super T> actual, T value)

Method Summary

Modifier and TypeMethod and Description
public void
request(long
the maximum number of items you want this Producer to produce, or Long.MAX_VALUE if you want the Producer to produce items at its own pace
n
)

Implements rx.Producer.request.

Request a certain maximum number of items from this Producer.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actualback to summary
pack-priv final Subscriber<? super T> actual
onceback to summary
pack-priv boolean once
valueback to summary
pack-priv final T value

Constructor Detail

WeakSingleProducerback to summary
public WeakSingleProducer(Subscriber<? super T> actual, T value)

Method Detail

requestback to summary
public void request(long n)

Implements rx.Producer.request.

Doc from rx.Producer.request.

Request a certain maximum number of items from this Producer. This is a way of requesting backpressure. To disable backpressure, pass Long.MAX_VALUE to this method.

Requests are additive but if a sequence of requests totals more than Long.MAX_VALUE then Long.MAX_VALUE requests will be actioned and the extras may be ignored. Arriving at Long.MAX_VALUE by addition of requests cannot be assumed to disable backpressure. For example, the code below may result in Long.MAX_VALUE requests being actioned only.

request(100);
request(Long.MAX_VALUE-1);
Parameters
n:long

the maximum number of items you want this Producer to produce, or Long.MAX_VALUE if you want the Producer to produce items at its own pace

Annotations
@Override