ConnectableObservable
ConnectableObservable resembles an ordinary Observable, except that it does not begin
emitting items when it is subscribed to, but only when its connect method is called. In this way you
can wait for all intended Observers to Observable#subscribe to the Observable
before the Observable begins emitting items.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Observable | Returns: an Observable that automatically connects to this ConnectableObservable when the first Observer subscribesReturns an Observable that automatically connects (at most once) to this ConnectableObservable when the first Observer subscribes. |
| public Observable | Returns: an Observable that automatically connects to this ConnectableObservable when the specified number of Subscribers subscribe to itthe number of subscribers to await before calling connect
on the ConnectableObservable. A non-positive value indicates
an immediate connection. numberOfSubscribers)Returns an Observable that automatically connects (at most once) to this ConnectableObservable when the specified number of Observers subscribe to it. |
| public Observable | Returns: an Observable that automatically connects to this ConnectableObservable when the specified number of Subscribers subscribe to it and calls the specified callback with the Subscription associated with the established connectionthe number of subscribers to await before calling connect
on the ConnectableObservable. A non-positive value indicates
an immediate connection. numberOfSubscribers, Consumer<? super Disposable> the callback Consumer that will receive the Subscription representing the
established connection connection)Returns an Observable that automatically connects (at most once) to this ConnectableObservable when the specified number of Subscribers subscribe to it and calls the specified callback with the Subscription associated with the established connection. |
| public abstract 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)Instructs the |
| public final Disposable | Returns: the subscription representing the connectionInstructs the |
| private ConnectableObservable | Returns: the ConnectableObservable to work withApply a workaround for a race condition with the regular publish().refCount() so that racing observers and refCount won't hang. |
| public Observable | Returns: anObservableReturns an |
| public final Observable | Returns: the new Observable instancethe number of subscribers required to connect to the upstream subscriberCount)Connects to the upstream |
| public final Observable | Returns: the new Observable instancethe time to wait before disconnecting after all subscribers unsubscribed timeout, TimeUnit the time unit of the timeout unit)Connects to the upstream |
| public final Observable | Returns: the new Observable instancethe time to wait before disconnecting after all subscribers unsubscribed timeout, TimeUnit the time unit of the timeout unit, Scheduler the target scheduler to wait on before disconnecting scheduler)Connects to the upstream |
| public final Observable | Returns: the new Observable instancethe number of subscribers required to connect to the upstream subscriberCount, long the time to wait before disconnecting after all subscribers unsubscribed timeout, TimeUnit the time unit of the timeout unit)Connects to the upstream |
| public final Observable | Returns: the new Observable instancethe number of subscribers required to connect to the upstream subscriberCount, long the time to wait before disconnecting after all subscribers unsubscribed timeout, TimeUnit the time unit of the timeout unit, Scheduler the target scheduler to wait on before disconnecting scheduler)Connects to the upstream |
| ConnectableObservable | back to summary |
|---|---|
| public ConnectableObservable() | |
| autoConnect | back to summary |
|---|---|
| public Observable Returns an Observable that automatically connects (at most once) to this ConnectableObservable when the first Observer subscribes.
The connection happens after the first subscription and happens at most once
during the lifetime of the returned Observable. If this ConnectableObservable
terminates, the connection is never renewed, no matter how Observers come
and go. Use
This overload does not allow disconnecting the connection established via
| |
| autoConnect | back to summary |
|---|---|
| public Observable Returns an Observable that automatically connects (at most once) to this ConnectableObservable when the specified number of Observers subscribe to it.
The connection happens after the given number of subscriptions and happens at most once
during the lifetime of the returned Observable. If this ConnectableObservable
terminates, the connection is never renewed, no matter how Observers come
and go. Use
This overload does not allow disconnecting the connection established via
| |
| autoConnect | back to summary |
|---|---|
| public Observable Returns an Observable that automatically connects (at most once) to this ConnectableObservable when the specified number of Subscribers subscribe to it and calls the specified callback with the Subscription associated with the established connection.
The connection happens after the given number of subscriptions and happens at most once
during the lifetime of the returned Observable. If this ConnectableObservable
terminates, the connection is never renewed, no matter how Observers come
and go. Use
| |
| connect | back to summary |
|---|---|
| public abstract void connect(Consumer<? super Disposable> connection) Instructs the
| |
| connect | back to summary |
|---|---|
| public final Disposable connect() Instructs the
To disconnect from a synchronous source, use the
| |
| onRefCount | back to summary |
|---|---|
| private ConnectableObservable Apply a workaround for a race condition with the regular publish().refCount() so that racing observers and refCount won't hang.
| |
| refCount | back to summary |
|---|---|
| public Observable Returns an
| |
| refCount | back to summary |
|---|---|
| public final Observable Connects to the upstream
History: 2.1.14 - experimental
| |
| refCount | back to summary |
|---|---|
| public final Observable Connects to the upstream
History: 2.1.14 - experimental
| |
| refCount | back to summary |
|---|---|
| public final Observable Connects to the upstream
History: 2.1.14 - experimental
| |
| refCount | back to summary |
|---|---|
| public final Observable Connects to the upstream
History: 2.1.14 - experimental
| |
| refCount | back to summary |
|---|---|
| public final Observable Connects to the upstream
History: 2.1.14 - experimental
| |