EsStreamSinkPromise
Description
A sink where the destination is provided later.
The sink is a normal sink that you can add events to immediately, but until #setDestinationSink: is called, the events will be buffered.
The same effect can be achieved by using an <EsStreamController> and adding it to the sink using sink addStream:
when the destination sink is ready. This class attempts to shortcut some overhead when possible. For example, if the sink only has events added after the destination sink has been set, those events are added directly to the sink.
Instance State
• sink: <EsStreamSink> The sink for this promise. When a destination sink is provided, events that have been passed to the sink will be forwarded to the destination. Events can be added to the sink either before or after a destination sink is set
Class Methods
fromFuture:
Convert an <EsFuture> that completes with an <EsStreamSink> to an <EsStreamSink>
This creates a sink using a sink promise, and sets the destination sink
to the result of the future when the future completes.
If the future completes with an error, the returned sink will instead
be closed. Its [sink done] future will contain the error.
Arguments:
sinkFuture - <EsFuture> that completes with an <EsStreamSink>
Answers:
<EsStreamSink>
new
Answers a new init instance of an <EsStreamSinkPromise>
Answers:
<EsStreamSinkPromise>
Instance Methods
setDestinationSink:
Sets a sink as the destination for events from the <EsStreamSinkPromise>'s
sink.
The promise's sink will act exactly as @destinationSink.
If the destination sink is set before events are added to sink, further
events are forwarded directly to @destinationSink.
If events are added to sink before setting the @destinationSink, they're
buffered until the destination is available.
A @destinationSink may be set at most once.
Either of #setDestinationSink: or #setError: may be called at most once.
Trying to call either of them again will fail.
Arguments:
destinationSink - <EsStreamSink>
setError:
Completes this to a closed sink whose [sink done] future emits @error
This is useful when the process of loading the sink fails.
Either of #setDestinationSink: or #setError: may be called at most once.
Trying to call either of them again will fail.
Arguments:
error - <Object>
setError:stackTrace:
Completes this to a closed sink whose [sink done] future emits @error
This is useful when the process of loading the sink fails.
Either of #setDestinationSink: or #setError: may be called at most once.
Trying to call either of them again will fail.
Arguments:
error - <Object>
sink
The sink for this promise
Answers:
<EsStreamSink>
Last modified date: 04/21/2022