EsStreamPromise
Description
A single-subscription stream where the contents are provided later.
It is generally recommended that you never create an <EsFuture> that completes with an <EsStream> because you can just directly create a stream that doesn't do anything until it's ready to do so. This class can be used to create such a stream.
The stream inst var is a normal stream that you can listen to immediately, but until either #setSourceStream or #setEmpty is called, the stream won't produce any events.
The same effect can be achieved by using a <EsStreamController> and adding the stream using #addStream: when both the controller's stream is listened to and the source stream is ready. This class attempts to shortcut some overhead when possible.
For example, if the stream inst var is only listened to after the source stream has been set, the listen is performed directly on the source stream.
Instance State
stream: <EsStream> The stream doing the actual work, is returned by #stream accessor
Class Methods
fromFuture:
  Convert an <EsFuture> (one that completes with an <EsStream>) to an <EsStream>.

     This creates a stream using a stream promise,
     and sets the source stream to the result of the future when the
     future completes.

     If the future completes with an error, the returned stream will
     instead contain just that error.

     Arguments:
        streamFuture - <EsFuture> that completes with <EsStream>
     Answers:
        <EsStream>
new
  Answer a new initialized instance of <EsStreamPromise>

     Answers:
        <EsStreamPromise>
Instance Methods
setEmpty
  Equivalent to setting an empty stream using #setSourceStream:.

     Any one of #setSourceStream:, #setEmpty, and #setError may be called at
     most once. Trying to call any of them again will fail.
setError:
  Completes this to a stream that emits @error and then closes.

     This is useful when the process of creating the data for the stream fails.

     Any one of #setSourceStream:, #setEmpty, and #setError:* may be called at
     most once. Trying to call any of them again will fail.

     Arguments:
        error - <Object>
setError:stackTrace:
  Completes this to a stream that emits @error and then closes.

     This is useful when the process of creating the data for the stream fails.

     Any one of #setSourceStream:, #setEmpty, and #setError:* may be called at
     most once. Trying to call any of them again will fail.

     Arguments:
        error - <Object>
        stackTrace - <EsAsyncStackTrace>
setSourceStream:
  Set a stream as the source of events for the <EsStreamPromise>'s `stream`

     The promise's `stream` will act exactly as @aSourceStream

     If the source stream is set before `stream` is listened to,
     the listen call on `stream` is forwarded directly to @aSourceStream

     If `stream` is listened to before setting the source stream,
     an intermediate subscription is created. It looks like a completely
     normal subscription, and can be paused or canceled, but it won't
     produce any events until a source stream is provided.

     If the `stream` subscription is canceled before a source stream is set,
     the source stream will be listened to and immediately canceled again.

     Otherwise, when the source stream is then set,
     it is immediately listened to, and its events are forwarded to the
     existing subscription.

     Any one of #setSourceStream:, #setEmpty, and #setError may be called at
     most once. Trying to call any of them again will fail.

     Arguments:
        aSourceStream - <EsStream>
stream
  The stream of this promise.

     This stream is always a single-subscription stream.

     When a source stream is provided, its events will be forwarded to
     listeners on this stream.

     The stream can be listened either before or after a source stream
     is set.

     Answers:
        <EsStream>
Last modified date: 04/21/2022