Top Description Inners Fields Constructors Methods
rx.internal.operators

public final Class OnSubscribeSwitchIfEmpty<T>

extends Object
implements Observable.OnSubscribe<T>
Class Inheritance
All Implemented Interfaces
rx.Observable.OnSubscribe, rx.functions.Action1, rx.functions.Action, rx.functions.Function
Type Parameters
<T>
the value type
Imports
java.util.concurrent.atomic.AtomicInteger, rx.*, rx.internal.producers.ProducerArbiter, rx.subscriptions.SerialSubscription

If the Observable completes without emitting any items, subscribe to an alternate Observable. Allows for similar functionality to rx.Observable#defaultIfEmpty(Object) except instead of one item being emitted when empty, the results of the given Observable will be emitted.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final Observable<? extends T>
pack-priv final Observable<? extends T>

Constructor Summary

AccessConstructor and Description
public
OnSubscribeSwitchIfEmpty(Observable<? extends T> source, Observable<? extends T> alternate)

Method Summary

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

Implements rx.functions.Action1.call.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

alternateback to summary
pack-priv final Observable<? extends T> alternate
sourceback to summary
pack-priv final Observable<? extends T> source

Constructor Detail

OnSubscribeSwitchIfEmptyback to summary
public OnSubscribeSwitchIfEmpty(Observable<? extends T> source, Observable<? extends T> alternate)

Method Detail

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

Implements rx.functions.Action1.call.

Annotations
@Override
rx.internal.operators back to summary

pack-priv final Class OnSubscribeSwitchIfEmpty.AlternateSubscriber<T>

extends Subscriber<T>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ProducerArbiter
private final Subscriber<? super T>

Constructor Summary

AccessConstructor and Description
pack-priv
AlternateSubscriber(Subscriber<? super T> child, ProducerArbiter arbiter)

Method Summary

Modifier and TypeMethod and Description
public void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(Throwable
the exception encountered by the Observable
e
)

Implements rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public void
onNext(T
the item emitted by the Observable
t
)

Implements rx.Observer.onNext.

Provides the Observer with a new item to observe.
public void
setProducer(final Producer
producer to be used by this subscriber or the other subscriber (or recursively its other subscriber) to make requests from
producer
)

Overrides rx.Subscriber.setProducer.

If other subscriber is set (by calling constructor Subscriber(Subscriber) or Subscriber(Subscriber, boolean)) then this method calls setProducer on the other subscriber.
Inherited from rx.Subscriber:
addisUnsubscribedonStartrequestunsubscribe

Field Detail

arbiterback to summary
private final ProducerArbiter arbiter
childback to summary
private final Subscriber<? super T> child

Constructor Detail

AlternateSubscriberback to summary
pack-priv AlternateSubscriber(Subscriber<? super T> child, ProducerArbiter arbiter)

Method Detail

onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Doc from rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@Override
onErrorback to summary
public void onError(Throwable e)

Implements rx.Observer.onError.

Doc from rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onCompleted.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@Override
onNextback to summary
public void onNext(T t)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override
setProducerback to summary
public void setProducer(final Producer producer)

Overrides rx.Subscriber.setProducer.

Doc from rx.Subscriber.setProducer.

If other subscriber is set (by calling constructor Subscriber(Subscriber) or Subscriber(Subscriber, boolean)) then this method calls setProducer on the other subscriber. If the other subscriber is not set and no requests have been made to this subscriber then p.request(Long.MAX_VALUE) is called. If the other subscriber is not set and some requests have been made to this subscriber then p.request(n) is called where n is the accumulated requests to this subscriber.

Parameters
producer:Producer

producer to be used by this subscriber or the other subscriber (or recursively its other subscriber) to make requests from

Annotations
@Override
rx.internal.operators back to summary

pack-priv final Class OnSubscribeSwitchIfEmpty.ParentSubscriber<T>

extends Subscriber<T>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv volatile boolean
private final Observable<? extends T>
private final ProducerArbiter
private final Subscriber<? super T>
private boolean
private final SerialSubscription
pack-priv final AtomicInteger

Constructor Summary

AccessConstructor and Description
pack-priv
ParentSubscriber(Subscriber<? super T> child, final SerialSubscription serial, ProducerArbiter arbiter, Observable<? extends T> alternate)

Method Summary

Modifier and TypeMethod and Description
public void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(Throwable
the exception encountered by the Observable
e
)

Implements rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public void
onNext(T
the item emitted by the Observable
t
)

Implements rx.Observer.onNext.

Provides the Observer with a new item to observe.
public void
setProducer(final Producer
producer to be used by this subscriber or the other subscriber (or recursively its other subscriber) to make requests from
producer
)

Overrides rx.Subscriber.setProducer.

If other subscriber is set (by calling constructor Subscriber(Subscriber) or Subscriber(Subscriber, boolean)) then this method calls setProducer on the other subscriber.
pack-priv void
subscribe(Observable<? extends T> source)

Inherited from rx.Subscriber:
addisUnsubscribedonStartrequestunsubscribe

Field Detail

activeback to summary
pack-priv volatile boolean active
alternateback to summary
private final Observable<? extends T> alternate
arbiterback to summary
private final ProducerArbiter arbiter
childback to summary
private final Subscriber<? super T> child
emptyback to summary
private boolean empty
serialback to summary
private final SerialSubscription serial
wipback to summary
pack-priv final AtomicInteger wip

Constructor Detail

ParentSubscriberback to summary
pack-priv ParentSubscriber(Subscriber<? super T> child, final SerialSubscription serial, ProducerArbiter arbiter, Observable<? extends T> alternate)

Method Detail

onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Doc from rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@Override
onErrorback to summary
public void onError(Throwable e)

Implements rx.Observer.onError.

Doc from rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onCompleted.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@Override
onNextback to summary
public void onNext(T t)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override
setProducerback to summary
public void setProducer(final Producer producer)

Overrides rx.Subscriber.setProducer.

Doc from rx.Subscriber.setProducer.

If other subscriber is set (by calling constructor Subscriber(Subscriber) or Subscriber(Subscriber, boolean)) then this method calls setProducer on the other subscriber. If the other subscriber is not set and no requests have been made to this subscriber then p.request(Long.MAX_VALUE) is called. If the other subscriber is not set and some requests have been made to this subscriber then p.request(n) is called where n is the accumulated requests to this subscriber.

Parameters
producer:Producer

producer to be used by this subscriber or the other subscriber (or recursively its other subscriber) to make requests from

Annotations
@Override
subscribeback to summary
pack-priv void subscribe(Observable<? extends T> source)