Class ConnectableMulti<T>
- java.lang.Object
-
- io.smallrye.mutiny.operators.AbstractMulti<T>
-
- io.smallrye.mutiny.operators.multi.multicast.ConnectableMulti<T>
-
- Type Parameters:
T- the type of item
- All Implemented Interfaces:
Multi<T>,org.reactivestreams.Publisher<T>
- Direct Known Subclasses:
MultiPublishOp
public abstract class ConnectableMulti<T> extends AbstractMulti<T>
AConnectableMultiis similar to a regularMulti, except that it does not begin emitting items (from upstream to downstream) when it is subscribed to, but only when itsconnect(io.smallrye.mutiny.operators.multi.multicast.ConnectableMultiConnection)method is called. This allows deferring the dispatching of events. For example, it can wait until a set number of subscribers have subscribed.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedConnectableMulti(Multi<T> upstream)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidconnect(ConnectableMultiConnection connection)Allows thisConnectableMultito start emitting the items from its upstreamMultito itsSubscribers.Multi<T>connectAfter(int numberOfSubscribers)Returns aMultithat connect to the upstream as soon as thenumberOfSubscriberssubscribers subscribe.Multi<T>referenceCount()Returns aMultithat stays connected to thisConnectableMultias long as there is at least one active subscription.Multi<T>referenceCount(int count, java.time.Duration duration)Connects to the upstreamConnectableMultiif the number of subscribers reaches the specified amount and disconnect after the specified duration after all subscribers have unsubscribed (cancelled their subscriptions).-
Methods inherited from class io.smallrye.mutiny.operators.AbstractMulti
broadcast, cache, collect, convert, emitOn, group, on, onCancellation, onCompletion, onFailure, onFailure, onFailure, onItem, onOverflow, onRequest, onSubscribe, onTermination, runSubscriptionOn, select, skip, subscribe, subscribe, subscribe, toHotStream, toUni, transform
-
-
-
-
Method Detail
-
connect
protected abstract void connect(ConnectableMultiConnection connection)
Allows thisConnectableMultito start emitting the items from its upstreamMultito itsSubscribers.- Parameters:
connection- the connection.
-
referenceCount
public Multi<T> referenceCount()
Returns aMultithat stays connected to thisConnectableMultias long as there is at least one active subscription.- Returns:
- a
Multi
-
referenceCount
public Multi<T> referenceCount(int count, java.time.Duration duration)
Connects to the upstreamConnectableMultiif the number of subscribers reaches the specified amount and disconnect after the specified duration after all subscribers have unsubscribed (cancelled their subscriptions).- Parameters:
count- the number of subscribers that trigger the emissionsduration- the duration, can benull, if set must be positive- Returns:
- the new Multi instance
-
connectAfter
public Multi<T> connectAfter(int numberOfSubscribers)
Returns aMultithat connect to the upstream as soon as thenumberOfSubscriberssubscribers subscribe. The connection stays opens even if the subscribers cancelled the subscription. Other subscribers can subscribe, it would not re-subscribe to the upstream.- Parameters:
numberOfSubscribers- the number of subscribe to reach before subscribing to upstream.- Returns:
- the multi
-
-