Top Description Inners Fields Constructors Methods
io.reactivex.internal.operators.observable

public final Class ObservablePublishAlt<T>

extends ConnectableObservable<T>
implements HasUpstreamObservableSource<T>, ResettableConnectable
Class Inheritance
All Implemented Interfaces
io.reactivex.internal.disposables.ResettableConnectable, io.reactivex.internal.fuseable.HasUpstreamObservableSource
Type Parameters
<T>
the element type
Imports
java.util.concurrent.atomic.*, io.reactivex.*, io.reactivex.disposables.Disposable, io.reactivex.exceptions.Exceptions, io.reactivex.functions.Consumer, io.reactivex.internal.disposables.*, io.reactivex.internal.fuseable.HasUpstreamObservableSource, io.reactivex.internal.util.ExceptionHelper, io.reactivex.observables.ConnectableObservable

Shares a single underlying connection to the upstream ObservableSource and multicasts events to all subscribed observers until the upstream completes or the connection is disposed.

The difference to ObservablePublish is that when the upstream terminates, late observers will receive that terminal event until the connection is disposed and the ConnectableObservable is reset to its fresh state.

Since
2.2.10

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ObservablePublishAlt.InnerDisposable<
the element type
T
>

Intercepts the dispose signal from the downstream and removes itself from the connection's observers array at most once.

pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicReference<ObservablePublishAlt.PublishConnection<T>>
pack-priv final ObservableSource<T>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
connect(Consumer<? super Disposable>
the action that receives the connection subscription before the subscription to source happens allowing the caller to synchronously disconnect a synchronous source
connection
)

Implements abstract io.reactivex.observables.ConnectableObservable.connect.

Instructs the ConnectableObservable to begin emitting the items from its underlying Observable to its Observers.
public void
resetIf(Disposable
the disposable received from a previous connect() call.
connection
)

Implements io.reactivex.internal.disposables.ResettableConnectable.resetIf.

Reset the connectable source only if the given Disposable connection instance is still representing a connection established by a previous connect() connection.
public ObservableSource<T>
source()

Implements io.reactivex.internal.fuseable.HasUpstreamObservableSource.source.

Returns the upstream source of this Observable.
protected void
subscribeActual(Observer<? super T>
the incoming Observer, never null
observer
)

Implements abstract io.reactivex.Observable.subscribeActual.

Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incoming Observers.
Inherited from io.reactivex.observables.ConnectableObservable:
autoConnectautoConnectautoConnectconnectrefCountrefCountrefCountrefCountrefCountrefCount

Field Detail

currentback to summary
pack-priv final AtomicReference<ObservablePublishAlt.PublishConnection<T>> current
sourceback to summary
pack-priv final ObservableSource<T> source

Constructor Detail

ObservablePublishAltback to summary
public ObservablePublishAlt(ObservableSource<T> source)

Method Detail

connectback to summary
public void connect(Consumer<? super Disposable> connection)

Implements abstract io.reactivex.observables.ConnectableObservable.connect.

Doc from io.reactivex.observables.ConnectableObservable.connect.

Instructs the ConnectableObservable to begin emitting the items from its underlying Observable to its Observers.

Parameters
connection:Consumer<? super Disposable>

the action that receives the connection subscription before the subscription to source happens allowing the caller to synchronously disconnect a synchronous source

Annotations
@Override
resetIfback to summary
public void resetIf(Disposable connection)

Implements io.reactivex.internal.disposables.ResettableConnectable.resetIf.

Doc from io.reactivex.internal.disposables.ResettableConnectable.resetIf.

Reset the connectable source only if the given Disposable connection instance is still representing a connection established by a previous connect() connection.

For example, an immediately previous connection should reset the connectable source:


Disposable d = connectable.connect();

((ResettableConnectable)connectable).resetIf(d);
However, if the connection indicator Disposable is from a much earlier connection, it should not affect the current connection:

Disposable d1 = connectable.connect();
d.dispose();

Disposable d2 = connectable.connect();

((ResettableConnectable)connectable).resetIf(d);

assertFalse(d2.isDisposed());
Parameters
connection:Disposable

the disposable received from a previous connect() call.

Annotations
@Override
@SuppressWarnings:unchecked
sourceback to summary
public ObservableSource<T> source()

Implements io.reactivex.internal.fuseable.HasUpstreamObservableSource.source.

Doc from io.reactivex.internal.fuseable.HasUpstreamObservableSource.source.

Returns the upstream source of this Observable.

Allows discovering the chain of observables.

Returns:ObservableSource<T>

the source ObservableSource

Annotations
@Override
subscribeActualback to summary
protected void subscribeActual(Observer<? super T> observer)

Implements abstract io.reactivex.Observable.subscribeActual.

Doc from io.reactivex.Observable.subscribeActual.

Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incoming Observers.

There is no need to call any of the plugin hooks on the current Observable instance or the Observer; all hooks and basic safeguards have been applied by subscribe(Observer) before this method gets called.

Parameters
observer:Observer<? super T>

the incoming Observer, never null

Annotations
@Override
io.reactivex.internal.operators.observable back to summary

pack-priv final Class ObservablePublishAlt.InnerDisposable<T>

extends AtomicReference<ObservablePublishAlt.PublishConnection<T>>
implements Disposable
Class Inheritance
All Implemented Interfaces
io.reactivex.disposables.Disposable
Type Parameters
<T>
the element type

Intercepts the dispose signal from the downstream and removes itself from the connection's observers array at most once.

Field Summary

Modifier and TypeField and Description
pack-priv final Observer<? super T>
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.
public boolean
isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
Inherited from java.util.concurrent.atomic.AtomicReference:
accumulateAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndAccumulategetAndSetgetAndUpdategetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

downstreamback to summary
pack-priv final Observer<? super T> downstream
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicReference.serialVersionUID.

Constructor Detail

InnerDisposableback to summary
pack-priv InnerDisposable(Observer<? super T> downstream, ObservablePublishAlt.PublishConnection<T> parent)

Method Detail

disposeback to summary
public void dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Doc from io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.

Annotations
@Override
isDisposedback to summary
public boolean isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Doc from io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.

Returns:boolean

true if this resource has been disposed

Annotations
@Override
io.reactivex.internal.operators.observable back to summary

pack-priv final Class ObservablePublishAlt.PublishConnection<T>

extends AtomicReference<ObservablePublishAlt.InnerDisposable<T>[]>
implements Observer<T>, Disposable
Class Inheritance
All Implemented Interfaces
io.reactivex.disposables.Disposable, io.reactivex.Observer

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicBoolean
pack-priv final AtomicReference<ObservablePublishAlt.PublishConnection<T>>
pack-priv static final ObservablePublishAlt.InnerDisposable<T>[]
pack-priv Throwable
private static final long
pack-priv static final ObservablePublishAlt.InnerDisposable<T>[]
pack-priv final AtomicReference<Disposable>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
public void
dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.
public boolean
isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
public void
onComplete()

Implements io.reactivex.Observer.onComplete.

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

Implements io.reactivex.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 io.reactivex.Observer.onNext.

Provides the Observer with a new item to observe.
public void
onSubscribe(Disposable
the Disposable instance whose Disposable#dispose() can be called anytime to cancel the connection
d
)

Implements io.reactivex.Observer.onSubscribe.

Provides the Observer with the means of cancelling (disposing) the connection (channel) with the Observable in both synchronous (from within onNext(Object)) and asynchronous manner.
public void
Inherited from java.util.concurrent.atomic.AtomicReference:
accumulateAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndAccumulategetAndSetgetAndUpdategetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

connectback to summary
pack-priv final AtomicBoolean connect
currentback to summary
pack-priv final AtomicReference<ObservablePublishAlt.PublishConnection<T>> current
EMPTYback to summary
pack-priv static final ObservablePublishAlt.InnerDisposable<T>[] EMPTY
Annotations
@SuppressWarnings:rawtypes
errorback to summary
pack-priv Throwable error
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicReference.serialVersionUID.

TERMINATEDback to summary
pack-priv static final ObservablePublishAlt.InnerDisposable<T>[] TERMINATED
Annotations
@SuppressWarnings:rawtypes
upstreamback to summary
pack-priv final AtomicReference<Disposable> upstream

Constructor Detail

PublishConnectionback to summary
pack-priv PublishConnection(AtomicReference<ObservablePublishAlt.PublishConnection<T>> current)
Annotations
@SuppressWarnings:unchecked

Method Detail

addback to summary
public boolean add(ObservablePublishAlt.InnerDisposable<T> inner)
disposeback to summary
public void dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Doc from io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.

Annotations
@SuppressWarnings:unchecked
@Override
isDisposedback to summary
public boolean isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Doc from io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.

Returns:boolean

true if this resource has been disposed

Annotations
@Override
onCompleteback to summary
public void onComplete()

Implements io.reactivex.Observer.onComplete.

Doc from io.reactivex.Observer.onComplete.

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
@SuppressWarnings:unchecked
onErrorback to summary
public void onError(Throwable e)

Implements io.reactivex.Observer.onError.

Doc from io.reactivex.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 onComplete.

Parameters
e:Throwable

the exception encountered by the Observable

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

Implements io.reactivex.Observer.onNext.

Doc from io.reactivex.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 onComplete or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override
onSubscribeback to summary
public void onSubscribe(Disposable d)

Implements io.reactivex.Observer.onSubscribe.

Doc from io.reactivex.Observer.onSubscribe.

Provides the Observer with the means of cancelling (disposing) the connection (channel) with the Observable in both synchronous (from within onNext(Object)) and asynchronous manner.

Parameters
d:Disposable

the Disposable instance whose Disposable#dispose() can be called anytime to cancel the connection

Annotations
@Override
removeback to summary
public void remove(ObservablePublishAlt.InnerDisposable<T> inner)
Annotations
@SuppressWarnings:unchecked