ConnectableFlowable
ConnectableFlowable resembles an ordinary Flowable, 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 Subscribers to Flowable#subscribe to the Flowable
before the Flowable begins emitting items.
When the upstream terminates, the ConnectableFlowable remains in this terminated state and,
depending on the actual underlying implementation, relays cached events to late Subscribers.
In order to reuse and restart this ConnectableFlowable, the reset() method has to be called.
When called, this ConnectableFlowable will appear as fresh, unconnected source to new Subscribers.
Disposing the connection will reset the ConnectableFlowable to its fresh state and there is no need to call
reset() in this case.
Note that although connect() and reset() are safe to call from multiple threads, it is recommended
a dedicated thread or business logic manages the connection or resetting of a ConnectableFlowable so that
there is no unwanted signal loss due to early connect() or reset() calls while Subscribers are
still being subscribed to to this ConnectableFlowable to receive signals from the get go.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public @NonNull Flowable | Returns: a newFlowable instance that automatically connects to this ConnectableFlowable
when the first Subscriber subscribesReturns a |
| public @NonNull Flowable | Returns: a newFlowable instance that automatically connects to this ConnectableFlowable
when the specified number of Subscribers subscribe to itthe number of subscribers to await before calling connect
on the numberOfSubscribers)ConnectableFlowable. A non-positive value indicates
an immediate connection.Returns a |
| public @NonNull Flowable | Returns: a newFlowable instance that automatically connects to this ConnectableFlowable
when the specified number of Subscribers subscribe to it and calls the
specified callback with the Disposable associated with the established connectionthe number of subscribers to await before calling connect
on the numberOfSubscribers, @NonNull Consumer<? super Disposable> ConnectableFlowable. A non-positive value indicates
an immediate connection.the callback connection)Consumer that will receive the Disposable representing the
established connectionReturns a |
| public abstract void | connect(@NonNull 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 @NonNull Disposable | Returns: the subscription representing the connectionInstructs the |
| public @NonNull Flowable | |
| public final @NonNull Flowable | |
| public final @NonNull Flowable | Returns: the newFlowable instancethe time to wait before disconnecting after all subscribers unsubscribed timeout, @NonNull TimeUnit the time unit of the timeout unit)Connects to the upstream |
| public final @NonNull Flowable | Returns: the newFlowable instancethe time to wait before disconnecting after all subscribers unsubscribed timeout, @NonNull TimeUnit the time unit of the timeout unit, @NonNull Scheduler the target scheduler to wait on before disconnecting scheduler)Connects to the upstream |
| public final @NonNull Flowable | Returns: the newFlowable instancethe number of subscribers required to connect to the upstream subscriberCount, long the time to wait before disconnecting after all subscribers unsubscribed timeout, @NonNull TimeUnit the time unit of the timeout unit)Connects to the upstream |
| public final @NonNull Flowable | Returns: the newFlowable instancethe number of subscribers required to connect to the upstream subscriberCount, long the time to wait before disconnecting after all subscribers unsubscribed timeout, @NonNull TimeUnit the time unit of the timeout unit, @NonNull Scheduler the target scheduler to wait on before disconnecting scheduler)Connects to the upstream |
| public abstract void |
| ConnectableFlowable | back to summary |
|---|---|
| public ConnectableFlowable() | |
| autoConnect | back to summary |
|---|---|
| public @NonNull Flowable Returns a
The connection happens after the first subscription and happens at most once
during the lifetime of the returned
This overload does not allow disconnecting the connection established via
| |
| autoConnect | back to summary |
|---|---|
| public @NonNull Flowable Returns a
The connection happens after the given number of subscriptions and happens at most once
during the lifetime of the returned
This overload does not allow disconnecting the connection established via
| |
| autoConnect | back to summary |
|---|---|
| public @NonNull Flowable Returns a
The connection happens after the given number of subscriptions and happens at most once
during the lifetime of the returned
| |
| connect | back to summary |
|---|---|
| public abstract void connect(@NonNull Consumer<? super Disposable> connection) Instructs the
| |
| connect | back to summary |
|---|---|
| public final @NonNull Disposable connect() Instructs the
To disconnect from a synchronous source, use the
| |
| refCount | back to summary |
|---|---|
| public @NonNull Flowable Returns a
| |
| refCount | back to summary |
|---|---|
| public final @NonNull Flowable Connects to the upstream
History: 2.1.14 - experimental
| |
| refCount | back to summary |
|---|---|
| public final @NonNull Flowable Connects to the upstream
History: 2.1.14 - experimental
| |
| refCount | back to summary |
|---|---|
| public final @NonNull Flowable Connects to the upstream
History: 2.1.14 - experimental
| |
| refCount | back to summary |
|---|---|
| public final @NonNull Flowable Connects to the upstream
History: 2.1.14 - experimental
| |
| refCount | back to summary |
|---|---|
| public final @NonNull Flowable Connects to the upstream
History: 2.1.14 - experimental
| |
| reset | back to summary |
|---|---|
| public abstract void reset() Resets this
Calling this method on a fresh or active
| |