Class UniSubscribe<T>
- java.lang.Object
-
- io.smallrye.mutiny.groups.UniSubscribe<T>
-
- Type Parameters:
T
- the type of item
public class UniSubscribe<T> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description UniSubscribe(AbstractUni<T> upstream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<T>
asCompletionStage()
LikewithSubscriber(UniSubscriber)
but provides aCompletableFuture
to retrieve the completed item (potentiallynull
) and allow chaining operations.java.util.concurrent.CompletableFuture<T>
asCompletionStage(Context context)
LikewithSubscriber(UniSubscriber)
but provides aCompletableFuture
to retrieve the completed item (potentiallynull
) and allow chaining operations.Cancellable
with(Context context, java.util.function.Consumer<? super T> onItemCallback)
LikewithSubscriber(UniSubscriber)
with creating an artificialUniSubscriber
calling theonItem
when the item is received.Cancellable
with(Context context, java.util.function.Consumer<? super T> onItemCallback, java.util.function.Consumer<? super java.lang.Throwable> onFailureCallback)
LikewithSubscriber(UniSubscriber)
with creating an artificialUniSubscriber
calling theonItem
andonFailure
callbacks when the events are received.Cancellable
with(java.util.function.Consumer<? super T> onItemCallback)
LikewithSubscriber(UniSubscriber)
with creating an artificialUniSubscriber
calling theonItem
when the item is received.Cancellable
with(java.util.function.Consumer<? super T> onItemCallback, java.util.function.Consumer<? super java.lang.Throwable> onFailureCallback)
LikewithSubscriber(UniSubscriber)
with creating an artificialUniSubscriber
calling theonItem
andonFailure
callbacks when the events are received.<S extends UniSubscriber<? super T>>
SwithSerializedSubscriber(S subscriber)
Requests theUni
to start computing the item, but wraps the provided subscriber in aUniSerializedSubscriber
instance that enforces correct events ordering.<S extends UniSubscriber<? super T>>
SwithSubscriber(S subscriber)
Requests theUni
to start computing the item.
-
-
-
Constructor Detail
-
UniSubscribe
public UniSubscribe(AbstractUni<T> upstream)
-
-
Method Detail
-
withSubscriber
public <S extends UniSubscriber<? super T>> S withSubscriber(S subscriber)
Requests theUni
to start computing the item.This is a "factory method" and can be called multiple times, each time starting a new
UniSubscription
. EachUniSubscription
will work for only a singleUniSubscriber
. AUniSubscriber
should only subscribe once to a singleUni
.If the
Uni
rejects the subscription attempt or otherwise fails it will fire afailure
event receiving byUniSubscriber.onFailure(Throwable)
.- Type Parameters:
S
- the type of subscriber returned- Parameters:
subscriber
- the subscriber, must not benull
- Returns:
- the passed subscriber
-
withSerializedSubscriber
public <S extends UniSubscriber<? super T>> S withSerializedSubscriber(S subscriber)
Requests theUni
to start computing the item, but wraps the provided subscriber in aUniSerializedSubscriber
instance that enforces correct events ordering.This is a "factory method" and can be called multiple times, each time starting a new
UniSubscription
. EachUniSubscription
will work for only a singleUniSubscriber
. AUniSubscriber
should only subscribe once to a singleUni
.If the
Uni
rejects the subscription attempt or otherwise fails it will fire afailure
event receiving byUniSubscriber.onFailure(Throwable)
.- Type Parameters:
S
- the type of subscriber returned- Parameters:
subscriber
- the subscriber, must not benull
- Returns:
- the passed subscriber
-
with
public Cancellable with(java.util.function.Consumer<? super T> onItemCallback, java.util.function.Consumer<? super java.lang.Throwable> onFailureCallback)
LikewithSubscriber(UniSubscriber)
with creating an artificialUniSubscriber
calling theonItem
andonFailure
callbacks when the events are received.Unlike
withSubscriber(UniSubscriber)
, this method returns the subscription that can be used to cancel the subscription.- Parameters:
onItemCallback
- callback invoked when the an item event is received, potentially called withnull
is received. The callback must not benull
onFailureCallback
- callback invoked when a failure event is received, must not benull
- Returns:
- an object to cancel the computation
-
with
@Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0") public Cancellable with(Context context, java.util.function.Consumer<? super T> onItemCallback, java.util.function.Consumer<? super java.lang.Throwable> onFailureCallback)
LikewithSubscriber(UniSubscriber)
with creating an artificialUniSubscriber
calling theonItem
andonFailure
callbacks when the events are received.Unlike
withSubscriber(UniSubscriber)
, this method returns the subscription that can be used to cancel the subscription.- Parameters:
context
- the context, must not benull
onItemCallback
- callback invoked when the an item event is received, potentially called withnull
is received. The callback must not benull
onFailureCallback
- callback invoked when a failure event is received, must not benull
- Returns:
- an object to cancel the computation
-
with
@Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0") public Cancellable with(Context context, java.util.function.Consumer<? super T> onItemCallback)
LikewithSubscriber(UniSubscriber)
with creating an artificialUniSubscriber
calling theonItem
when the item is received.Unlike
withSubscriber(UniSubscriber)
, this method returns the subscription that can be used to cancel the subscription.Unlike
with(Consumer, Consumer)
, this method does not handle failure, and the failure event is dropped.- Parameters:
context
- the context, must not benull
onItemCallback
- callback invoked when the an item event is received, potentially called withnull
is received. The callback must not benull
- Returns:
- an object to cancel the computation
-
with
public Cancellable with(java.util.function.Consumer<? super T> onItemCallback)
LikewithSubscriber(UniSubscriber)
with creating an artificialUniSubscriber
calling theonItem
when the item is received.Unlike
withSubscriber(UniSubscriber)
, this method returns the subscription that can be used to cancel the subscription.Unlike
with(Consumer, Consumer)
, this method does not handle failure, and the failure event is dropped.- Parameters:
onItemCallback
- callback invoked when the an item event is received, potentially called withnull
is received. The callback must not benull
- Returns:
- an object to cancel the computation
-
asCompletionStage
public java.util.concurrent.CompletableFuture<T> asCompletionStage()
LikewithSubscriber(UniSubscriber)
but provides aCompletableFuture
to retrieve the completed item (potentiallynull
) and allow chaining operations.- Returns:
- a
CompletableFuture
to retrieve the item and chain operations on the resolved item or failure. The returnedCompletableFuture
can also be used to cancel the computation.
-
asCompletionStage
@Experimental("Context support is a new experimental API introduced in Mutiny 1.3.0") public java.util.concurrent.CompletableFuture<T> asCompletionStage(Context context)
LikewithSubscriber(UniSubscriber)
but provides aCompletableFuture
to retrieve the completed item (potentiallynull
) and allow chaining operations.- Parameters:
context
- the context, must not benull
- Returns:
- a
CompletableFuture
to retrieve the item and chain operations on the resolved item or failure. The returnedCompletableFuture
can also be used to cancel the computation.
-
-