public abstract class

ConnectableFlowable

extends Flowable<T>
java.lang.Object
   ↳ io.reactivex.Flowable<T>
     ↳ io.reactivex.flowables.ConnectableFlowable<T>

Class Overview

A ConnectableObservable 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 subscribe() to the Observable before the Observable begins emitting items.

Summary

Public Constructors
ConnectableFlowable()
Public Methods
Flowable<T> autoConnect(int numberOfSubscribers, Consumer<? super Disposable> connection)
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 connection.
Flowable<T> autoConnect()
Returns an Observable that automatically connects to this ConnectableObservable when the first Subscriber subscribes.
Flowable<T> autoConnect(int numberOfSubscribers)
Returns an Observable that automatically connects to this ConnectableObservable when the specified number of Subscribers subscribe to it.
final Disposable connect()
Instructs the ConnectableObservable to begin emitting the items from its underlying Flowable to its Subscribers.
abstract void connect(Consumer<? super Disposable> connection)
Instructs the ConnectableObservable to begin emitting the items from its underlying Flowable to its Subscribers.
Flowable<T> refCount()
Returns an Observable that stays connected to this ConnectableObservable as long as there is at least one subscription to this ConnectableObservable.
[Expand]
Inherited Methods
From class io.reactivex.Flowable
From class java.lang.Object
From interface org.reactivestreams.Publisher

Public Constructors

public ConnectableFlowable ()

Public Methods

public Flowable<T> autoConnect (int numberOfSubscribers, Consumer<? super Disposable> connection)

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 connection.

Parameters
numberOfSubscribers the number of subscribers to await before calling connect on the ConnectableObservable. A non-positive value indicates an immediate connection.
connection the callback Consumer that will receive the Subscription representing the established connection
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 connection

public Flowable<T> autoConnect ()

Returns an Observable that automatically connects to this ConnectableObservable when the first Subscriber subscribes.

Returns
  • an Observable that automatically connects to this ConnectableObservable when the first Subscriber subscribes

public Flowable<T> autoConnect (int numberOfSubscribers)

Returns an Observable that automatically connects to this ConnectableObservable when the specified number of Subscribers subscribe to it.

Parameters
numberOfSubscribers the number of subscribers to await before calling connect on the ConnectableObservable. A non-positive value indicates an immediate connection.
Returns
  • an Observable that automatically connects to this ConnectableObservable when the specified number of Subscribers subscribe to it

public final Disposable connect ()

Instructs the ConnectableObservable to begin emitting the items from its underlying Flowable to its Subscribers.

To disconnect from a synchronous source, use the connect(io.reactivex.functions.Consumer) method.

Returns
  • the subscription representing the connection

public abstract void connect (Consumer<? super Disposable> connection)

Instructs the ConnectableObservable to begin emitting the items from its underlying Flowable to its Subscribers.

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

public Flowable<T> refCount ()

Returns an Observable that stays connected to this ConnectableObservable as long as there is at least one subscription to this ConnectableObservable.

Returns