Top Description Methods
reactor.core.publisher

public Interface MonoSink<T>

Known Direct Implementers
reactor.core.publisher.MonoCreate.DefaultMonoSink
Type Parameters
<T>
the value type emitted
Imports
java.util.function.Consumer, .Function, .LongConsumer, org.reactivestreams.Subscription, reactor.core.CoreSubscriber, .Disposable, reactor.util.annotation.Nullable, reactor.util.context.Context, .ContextView

Wrapper API around an actual downstream Subscriber for emitting nothing, a single value or an error (mutually exclusive).

Method Summary

Modifier and TypeMethod and Description
public default ContextView

Returns:

the current subscriber ContextView.
contextView
()

Return the current subscriber's context as a ContextView for inspection.

public Context
currentContext()

Deprecated To be removed in 3.6.0 at the earliest. Prefer using #contextView() instead.
Return the current subscriber Context.
public void
error(Throwable
the exception to complete with
e
)

Terminate with the given exception

Calling this method multiple times or after the other terminating methods is an unsupported operation.

public MonoSink<T>

Returns:

the MonoSink with a cancellation callback
onCancel
(Disposable
the Disposable to use as a callback
d
)

Attach a Disposable as a callback for when this MonoSink is cancelled.

public MonoSink<T>

Returns:

the MonoSink with a callback invoked on any terminal signal or on cancellation
onDispose
(Disposable
the Disposable to use as a callback
d
)

Attach a Disposable as a callback for when this MonoSink is effectively disposed, that is it cannot be used anymore.

public MonoSink<T>

Returns:

MonoSink with a consumer that is notified of requests
onRequest
(LongConsumer
the consumer to invoke on request
consumer
)

Attaches a LongConsumer to this MonoSink that will be notified of any request to this sink.

public void
success()

Complete without any value.

public void
success(T
the value to complete with
value
)

Complete this Mono with the given value.

Method Detail

contextViewback to summary
public default ContextView contextView()

Return the current subscriber's context as a ContextView for inspection.

Context can be enriched downstream via Mono#contextWrite(Function) operator or directly by a child subscriber overriding CoreSubscriber#currentContext().

Returns:ContextView

the current subscriber ContextView.

currentContextback to summary
public Context currentContext()

Deprecated

To be removed in 3.6.0 at the earliest. Prefer using #contextView() instead.

Return the current subscriber Context.

Context can be enriched via Mono#contextWrite(Function) operator or directly by a child subscriber overriding CoreSubscriber#currentContext()

Annotations
@Deprecated
errorback to summary
public void error(Throwable e)

Terminate with the given exception

Calling this method multiple times or after the other terminating methods is an unsupported operation. It will discard the exception through the Hooks#onErrorDropped(Consumer) hook. This is to avoid complete and silent swallowing of the exception.

Parameters
e:Throwable

the exception to complete with

onCancelback to summary
public MonoSink<T> onCancel(Disposable d)

Attach a Disposable as a callback for when this MonoSink is cancelled. At most one callback can be registered, and subsequent calls to this method will result in the immediate disposal of the extraneous Disposable.

The callback is only relevant when the downstream Subscription is cancelled.

Parameters
d:Disposable

the Disposable to use as a callback

Returns:MonoSink<T>

the MonoSink with a cancellation callback

See Also
onDispose(Disposable) for a callback that covers cancellation AND terminal signals
onDisposeback to summary
public MonoSink<T> onDispose(Disposable d)

Attach a Disposable as a callback for when this MonoSink is effectively disposed, that is it cannot be used anymore. This includes both having played terminal signals (onComplete, onError) and having been cancelled (see onCancel(Disposable)). At most one callback can be registered, and subsequent calls to this method will result in the immediate disposal of the extraneous Disposable.

Note that the "dispose" term is used from the perspective of the sink. Not to be confused with Mono#subscribe()'s Disposable#dispose() method, which maps to disposing the Subscription (effectively, a Subscription#cancel() signal).

Parameters
d:Disposable

the Disposable to use as a callback

Returns:MonoSink<T>

the MonoSink with a callback invoked on any terminal signal or on cancellation

See Also
onCancel(Disposable) for a cancellation-only callback
onRequestback to summary
public MonoSink<T> onRequest(LongConsumer consumer)

Attaches a LongConsumer to this MonoSink that will be notified of any request to this sink.

Parameters
consumer:LongConsumer

the consumer to invoke on request

Returns:MonoSink<T>

MonoSink with a consumer that is notified of requests

successback to summary
public void success()

Complete without any value.

Calling this method multiple times or after the other terminating methods has no effect.

successback to summary
public void success(T value)

Complete this Mono with the given value.

Calling this method multiple times or after the other terminating methods has no effect (the value is dropped). Calling this method with a null value will be silently accepted as a call to success() by standard implementations.

Parameters
value:T

the value to complete with