Top Description Fields Constructors Methods
reactor.core.publisher

public abstract Class ConnectableFlux<T>

extends Flux<T>
Class Inheritance
Known Direct Subclasses
reactor.core.publisher.FluxPublish, reactor.core.publisher.InternalConnectableFluxOperator, reactor.core.publisher.FluxReplay
Type Parameters
<T>
the input and output value type
Imports
java.time.Duration, java.util.function.Consumer, reactor.core.Disposable, .Fuseable, reactor.core.scheduler.Scheduler, .Schedulers

The abstract base class for connectable publishers that let subscribers pile up before they connect to their data source.
See Also
publish, Reactive-Streams-Commons

Field Summary

Modifier and TypeField and Description
pack-priv static final Consumer<Disposable>
Inherited from reactor.core.publisher.Flux:
ALWAYS_BOOLEAN_SUPPLIERIDENTITY_FUNCTIONLIST_SUPPLIEROBJECT_EQUALSET_SUPPLIERTUPLE2_BIFUNCTION

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final Flux<T>

Returns:

a Flux that connects to the upstream source when the first org.reactivestreams.Subscriber subscribes
autoConnect
()

Connects this ConnectableFlux to the upstream source when the first org.reactivestreams.Subscriber subscribes.

public final Flux<T>

Returns:

a Flux that connects to the upstream source when the given amount of Subscribers subscribed
autoConnect
(int
the minimum number of subscribers
minSubscribers
)

Connects this ConnectableFlux to the upstream source when the specified amount of org.reactivestreams.Subscriber subscribes.

public final Flux<T>

Returns:

a Flux that connects to the upstream source when the given amount of subscribers subscribed
autoConnect
(int
the minimum number of subscribers
minSubscribers
,
Consumer<? super Disposable>
the consumer that will receive the Disposable that allows disconnecting
cancelSupport
)

Connects this ConnectableFlux to the upstream source when the specified amount of org.reactivestreams.Subscriber subscribes and calls the supplied consumer with a Disposable that allows disconnecting.

public final Disposable

Returns:

the Disposable that allows disconnecting the connection after.
connect
()

Connect this ConnectableFlux to its source and return a Disposable that can be used for disconnecting.

public abstract void
connect(Consumer<? super Disposable>
the callback is called with a Disposable instance that can be called to disconnect the source, even synchronously.
cancelSupport
)

Connects this ConnectableFlux to its source and sends a Disposable to a callback that can be used for disconnecting.

public final ConnectableFlux<T>
hide()

Overrides reactor.core.publisher.Flux.hide.

Hides the identities of this Flux instance.
public final Flux<T>

Returns:

a reference counting Flux
refCount
()

Connects to the upstream source when the first org.reactivestreams.Subscriber subscribes and disconnects when all Subscribers cancelled or the upstream source completed.

public final Flux<T>

Returns:

a reference counting Flux
refCount
(int
the number of subscribers expected to subscribe before connection
minSubscribers
)

Connects to the upstream source when the given number of org.reactivestreams.Subscriber subscribes and disconnects when all Subscribers cancelled or the upstream source completed.

public final Flux<T>

Returns:

a reference counting Flux with a grace period for disconnection
refCount
(int
the number of subscribers expected to subscribe before connection
minSubscribers
,
Duration
the Duration for which to wait for new subscribers before actually disconnecting when all subscribers have cancelled.
gracePeriod
)

Connects to the upstream source when the given number of org.reactivestreams.Subscriber subscribes.

public final Flux<T>

Returns:

a reference counting Flux with a grace period for disconnection
refCount
(int
the number of subscribers expected to subscribe before connection
minSubscribers
,
Duration
the Duration for which to wait for new subscribers before actually disconnecting when all subscribers have cancelled.
gracePeriod
,
Scheduler
the Scheduler on which to run timeouts
scheduler
)

Connects to the upstream source when the given number of org.reactivestreams.Subscriber subscribes.

Inherited from reactor.core.publisher.Flux:
allanyasblockFirstblockFirstblockLastblockLastbufferbufferbufferbufferbufferbufferbufferbufferbufferbufferbufferbufferTimeoutbufferTimeoutbufferTimeoutbufferTimeoutbufferTimeoutbufferTimeoutbufferTimeoutbufferTimeoutbufferUntilbufferUntilbufferUntilChangedbufferUntilChangedbufferUntilChangedbufferWhenbufferWhenbufferWhilecachecachecachecachecachecachecancelOncastcheckpointcheckpointcheckpointcollectcollectcollectListcollectMapcollectMapcollectMapcollectMultimapcollectMultimapcollectMultimapcollectSortedListcollectSortedListcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestcombineLatestconcatconcatconcatconcatconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatDelayErrorconcatMapconcatMapconcatMapDelayErrorconcatMapDelayErrorconcatMapDelayErrorconcatMapIterableconcatMapIterableconcatWithconcatWithValuescontextCapturecontextWritecontextWritecountcountingBooleanSuppliercountingPredicatecreatecreatedefaultIfEmptydeferdeferContextualdelayElementsdelayElementsdelaySequencedelaySequencedelaySubscriptiondelaySubscriptiondelaySubscriptiondelayUntildematerializedistinctdistinctdistinctdistinctdistinctUntilChangeddistinctUntilChangeddistinctUntilChangeddoAfterTerminatedoFinallydoFirstdoOnCanceldoOnCompletedoOnDiscarddoOnEachdoOnErrordoOnErrordoOnErrordoOnNextdoOnRequestdoOnSignaldoOnSubscribedoOnTerminateelapsedelapsedelementAtelementAtemptyequalPredicateerrorerrorerrorexpandexpandexpandDeepexpandDeepfilterfilterWhenfilterWhenfirstfirstfirstWithSignalfirstWithSignalfirstWithValuefirstWithValueflatMapflatMapflatMapflatMapflatMapflatMapDelayErrorflatMapIterableflatMapIterableflatMapSequentialflatMapSequentialflatMapSequentialflatMapSequentialflatMapSequentialDelayErrorfromfromArrayfromIterablefromStreamfromStreamgenerategenerategenerategetPrefetchgroupBygroupBygroupBygroupBygroupJoinhandlehasElementhasElementshashSetSupplieridentityFunctionignoreElementsindexindexintervalintervalintervalintervaljoinjustjustlastlastlimitRatelimitRatelimitRequestlistSupplierloglogloglogloglogmapmapNotNullmaterializemergemergemergemergemergemergemergemergeComparingmergeComparingmergeComparingmergeComparingDelayErrormergeComparingWithmergeDelayErrormergeOrderedmergeOrderedmergeOrderedmergeOrderedWithmergePrioritymergePrioritymergePrioritymergePriorityDelayErrormergeSequentialmergeSequentialmergeSequentialmergeSequentialmergeSequentialmergeSequentialmergeSequentialmergeSequentialmergeSequentialmergeSequentialDelayErrormergeSequentialDelayErrormergeSequentialDelayErrormergeWithmetricsnamenevernextofTypeonAssemblyonAssemblyonBackpressureBufferonBackpressureBufferonBackpressureBufferonBackpressureBufferonBackpressureBufferonBackpressureBufferonBackpressureBufferonBackpressureDroponBackpressureDroponBackpressureErroronBackpressureLatestonErrorCompleteonErrorCompleteonErrorCompleteonErrorContinueonErrorContinueonErrorContinueonErrorMaponErrorMaponErrorMaponErrorResumeonErrorResumeonErrorResumeonErrorReturnonErrorReturnonErrorReturnonErrorStoponTerminateDetachorparallelparallelparallelpublishpublishpublishpublishpublishNextpublishOnpublishOnpublishOnpublishOnpushpushrangereducereducereduceWithrepeatrepeatrepeatrepeatrepeatWhenreplayreplayreplayreplayreplayreplayretryretryretryWhensamplesamplesampleFirstsampleFirstsampleTimeoutsampleTimeoutscanscanscanWithshareshareNextsinglesinglesingleOrEmptyskipskipskipskipLastskipUntilskipUntilOtherskipWhilesortsortstartWithstartWithstartWithsubscribesubscribesubscribesubscribesubscribesubscribesubscribesubscribesubscribeOnsubscribeOnsubscribeWithswitchIfEmptyswitchMapswitchMapswitchOnFirstswitchOnFirstswitchOnNextswitchOnNexttagtaketaketaketaketakeLasttakeUntiltakeUntilOthertakeWhiletaptaptapthenthenthenEmptythenManytimedtimedtimeouttimeouttimeouttimeouttimeouttimeouttimeouttimestamptimestamptoIterabletoIterabletoIterabletoStreamtoStreamtoStringtransformtransformDeferredtransformDeferredContextualtuple2FunctionusingusingusingWhenusingWhenwindowwindowwindowwindowwindowwindowwindowwindowTimeoutwindowTimeoutwindowTimeoutwindowTimeoutwindowUntilwindowUntilwindowUntilwindowUntilChangedwindowUntilChangedwindowUntilChangedwindowWhenwindowWhilewindowWhilewithLatestFromwrapwrapToMonozipzipzipzipzipzipzipzipzipzipzipzipzipzipWithzipWithzipWithzipWithzipWithIterablezipWithIterable

Field Detail

NOOP_DISCONNECTback to summary
pack-priv static final Consumer<Disposable> NOOP_DISCONNECT

Constructor Detail

ConnectableFluxback to summary
public ConnectableFlux()

Method Detail

autoConnectback to summary
public final Flux<T> autoConnect()

Connects this ConnectableFlux to the upstream source when the first org.reactivestreams.Subscriber subscribes.

Returns:Flux<T>

a Flux that connects to the upstream source when the first org.reactivestreams.Subscriber subscribes

autoConnectback to summary
public final Flux<T> autoConnect(int minSubscribers)

Connects this ConnectableFlux to the upstream source when the specified amount of org.reactivestreams.Subscriber subscribes.

Subscribing and immediately unsubscribing still contributes to the counter that triggers the connection.

Parameters
minSubscribers:int

the minimum number of subscribers

Returns:Flux<T>

a Flux that connects to the upstream source when the given amount of Subscribers subscribed

autoConnectback to summary
public final Flux<T> autoConnect(int minSubscribers, Consumer<? super Disposable> cancelSupport)

Connects this ConnectableFlux to the upstream source when the specified amount of org.reactivestreams.Subscriber subscribes and calls the supplied consumer with a Disposable that allows disconnecting.

Parameters
minSubscribers:int

the minimum number of subscribers

cancelSupport:Consumer<? super Disposable>

the consumer that will receive the Disposable that allows disconnecting

Returns:Flux<T>

a Flux that connects to the upstream source when the given amount of subscribers subscribed

connectback to summary
public final Disposable connect()

Connect this ConnectableFlux to its source and return a Disposable that can be used for disconnecting.

Returns:Disposable

the Disposable that allows disconnecting the connection after.

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

Connects this ConnectableFlux to its source and sends a Disposable to a callback that can be used for disconnecting.

The call should be idempotent in respect of connecting the first and subsequent times. In addition, the disconnection should be tied to a particular connection (so two different connections can't disconnect the other).

Parameters
cancelSupport:Consumer<? super Disposable>

the callback is called with a Disposable instance that can be called to disconnect the source, even synchronously.

hideback to summary
public final ConnectableFlux<T> hide()

Overrides reactor.core.publisher.Flux.hide.

Doc from reactor.core.publisher.Flux.hide.

Hides the identities of this Flux instance.

The main purpose of this operator is to prevent certain identity-based optimizations from happening, mostly for diagnostic purposes.

Returns:ConnectableFlux<T>

a new Flux preventing Publisher / Subscription based Reactor optimizations

Annotations
@Override
refCountback to summary
public final Flux<T> refCount()

Connects to the upstream source when the first org.reactivestreams.Subscriber subscribes and disconnects when all Subscribers cancelled or the upstream source completed.

Returns:Flux<T>

a reference counting Flux

refCountback to summary
public final Flux<T> refCount(int minSubscribers)

Connects to the upstream source when the given number of org.reactivestreams.Subscriber subscribes and disconnects when all Subscribers cancelled or the upstream source completed.

Parameters
minSubscribers:int

the number of subscribers expected to subscribe before connection

Returns:Flux<T>

a reference counting Flux

refCountback to summary
public final Flux<T> refCount(int minSubscribers, Duration gracePeriod)

Connects to the upstream source when the given number of org.reactivestreams.Subscriber subscribes. Disconnection can happen in two scenarios: when the upstream source completes (or errors) then there is an immediate disconnection. However, when all subscribers have cancelled, a deferred disconnection is scheduled. If any new subscriber comes in during the gracePeriod that follows, the disconnection is cancelled.

Parameters
minSubscribers:int

the number of subscribers expected to subscribe before connection

gracePeriod:Duration

the Duration for which to wait for new subscribers before actually disconnecting when all subscribers have cancelled.

Returns:Flux<T>

a reference counting Flux with a grace period for disconnection

refCountback to summary
public final Flux<T> refCount(int minSubscribers, Duration gracePeriod, Scheduler scheduler)

Connects to the upstream source when the given number of org.reactivestreams.Subscriber subscribes. Disconnection can happen in two scenarios: when the upstream source completes (or errors) then there is an immediate disconnection. However, when all subscribers have cancelled, a deferred disconnection is scheduled. If any new subscriber comes in during the gracePeriod that follows, the disconnection is cancelled.

Parameters
minSubscribers:int

the number of subscribers expected to subscribe before connection

gracePeriod:Duration

the Duration for which to wait for new subscribers before actually disconnecting when all subscribers have cancelled.

scheduler:Scheduler

the Scheduler on which to run timeouts

Returns:Flux<T>

a reference counting Flux with a grace period for disconnection