Top Description Constructors Methods
rx.observables

public abstract Class ConnectableObservable<T>

extends Observable<T>
Class Inheritance
Known Direct Subclasses
rx.internal.operators.OperatorMulticast, rx.internal.operators.OperatorPublish, rx.internal.operators.OperatorReplay
Type Parameters
<T>
the type of items emitted by the ConnectableObservable
Imports
rx.*, rx.functions.*, rx.internal.operators.*

A 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 Subscribers to Observable#subscribe to the Observable before the Observable begins emitting items.

See Also
RxJava Wiki: Connectable Observable Operators

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public Observable<T>

Returns:

an Observable that automatically connects to this ConnectableObservable when the first Subscriber subscribes
autoConnect
()

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

public Observable<T>

Returns:

an Observable that automatically connects to this ConnectableObservable when the specified number of Subscribers subscribe to it
autoConnect
(int
the 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 to this ConnectableObservable when the specified number of Subscribers subscribe to it.

public Observable<T>

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
autoConnect
(int
the number of subscribers to await before calling connect on the ConnectableObservable. A non-positive value indicates an immediate connection.
numberOfSubscribers
,
Action1<? super Subscription>
the callback Action1 that will receive the Subscription representing the established connection
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 final Subscription

Returns:

the subscription representing the connection
connect
()

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

public abstract void
connect(Action1<? super Subscription>
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 ConnectableObservable to begin emitting the items from its underlying Observable to its Subscribers.

public Observable<T>

Returns:

a Observable
refCount
()

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

Inherited from rx.Observable:
allambambambambambambambambambambWithasObservablebufferbufferbufferbufferbufferbufferbufferbufferbufferbufferbufferbuffercachecachecacheWithInitialCapacitycastcollectcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestDelayErrorcomposeconcatconcatconcatconcatconcatconcatconcatconcatconcatconcatconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatEagerconcatMapconcatMapDelayErrorconcatMapEagerconcatMapEagerconcatMapEagerconcatMapIterableconcatWithcontainscountcountLongcreatecreatecreatecreatedebouncedebouncedebouncedefaultIfEmptydeferdelaydelaydelaydelaydelaySubscriptiondelaySubscriptiondelaySubscriptiondelaySubscriptiondematerializedistinctdistinctdistinctUntilChangeddistinctUntilChangeddistinctUntilChangeddoAfterTerminatedoOnCompleteddoOnEachdoOnEachdoOnErrordoOnNextdoOnRequestdoOnSubscribedoOnTerminatedoOnUnsubscribeelementAtelementAtOrDefaultemptyerrorexistsfilterfinallyDofirstfirstfirstOrDefaultfirstOrDefaultflatMapflatMapflatMapflatMapflatMapflatMapflatMapCompletableflatMapCompletableflatMapCompletableflatMapIterableflatMapIterableflatMapIterableflatMapIterableflatMapSingleflatMapSingleflatMapSingleforEachforEachforEachfromfromfromfromfromfromCallablegroupBygroupBygroupBygroupBygroupJoinignoreElementsintervalintervalintervalintervalisEmptyjoinjustjustjustjustjustjustjustjustjustjustlastlastlastOrDefaultlastOrDefaultliftlimitmapmaterializemergemergemergemergemergemergemergemergemergemergemergemergemergemergemergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeDelayErrormergeWithnestneverobserveOnobserveOnobserveOnobserveOnofTypeonBackpressureBufferonBackpressureBufferonBackpressureBufferonBackpressureBufferonBackpressureDroponBackpressureDroponBackpressureLatestonErrorResumeNextonErrorResumeNextonErrorReturnonExceptionResumeNextonTerminateDetachpublishpublishrangerangerebatchRequestsreducereducerepeatrepeatrepeatrepeatrepeatWhenrepeatWhenreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayreplayretryretryretryretryWhenretryWhensamplesamplesamplescanscansequenceEqualsequenceEqualserializesharesinglesinglesingleOrDefaultsingleOrDefaultskipskipskipskipLastskipLastskipLastskipUntilskipWhilesortedsortedstartWithstartWithstartWithstartWithstartWithstartWithstartWithstartWithstartWithstartWithstartWithsubscribesubscribesubscribesubscribesubscribesubscribesubscribeOnsubscribeOnswitchIfEmptyswitchMapswitchMapDelayErrorswitchOnNextswitchOnNextDelayErrortaketaketaketakeFirsttakeLasttakeLasttakeLasttakeLasttakeLasttakeLastBuffertakeLastBuffertakeLastBuffertakeLastBuffertakeLastBuffertakeUntiltakeUntiltakeWhiletesttestthrottleFirstthrottleFirstthrottleLastthrottleLastthrottleWithTimeoutthrottleWithTimeouttimeIntervaltimeIntervaltimeouttimeouttimeouttimeouttimeouttimeouttimeouttimeouttimertimertimertimertimestamptimestamptotoBlockingtoCompletabletoListtoMaptoMaptoMaptoMultimaptoMultimaptoMultimaptoMultimaptoSingletoSortedListtoSortedListtoSortedListtoSortedListunsafeCreateunsafeSubscribeunsubscribeOnusingusingwindowwindowwindowwindowwindowwindowwindowwindowwindowwindowwindowwindowwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromwithLatestFromzipzipzipzipzipzipzipzipzipzipzipzipWithzipWith

Constructor Detail

ConnectableObservableback to summary
protected ConnectableObservable(Observable.OnSubscribe<T> onSubscribe)

Method Detail

autoConnectback to summary
public Observable<T> autoConnect()

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

Returns:Observable<T>

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

Since
1.2
autoConnectback to summary
public Observable<T> autoConnect(int numberOfSubscribers)

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

Parameters
numberOfSubscribers:int

the number of subscribers to await before calling connect on the ConnectableObservable. A non-positive value indicates an immediate connection.

Returns:Observable<T>

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

Since
1.2
autoConnectback to summary
public Observable<T> autoConnect(int numberOfSubscribers, Action1<? super Subscription> 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:int

the number of subscribers to await before calling connect on the ConnectableObservable. A non-positive value indicates an immediate connection.

connection:Action1<? super Subscription>

the callback Action1 that will receive the Subscription representing the established connection

Returns:Observable<T>

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

Since
1.2
connectback to summary
public final Subscription connect()

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

To disconnect from a synchronous source, use the connect(rx.functions.Action1) method.

Returns:Subscription

the subscription representing the connection

See Also
ReactiveX documentation: Connect
connectback to summary
public abstract void connect(Action1<? super Subscription> connection)

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

Parameters
connection:Action1<? super Subscription>

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

See Also
ReactiveX documentation: Connect
refCountback to summary
public Observable<T> refCount()

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

Returns:Observable<T>

a Observable

See Also
ReactiveX documentation: RefCount