EsStreamIterator
Description
Iterates over the values of a <EsStream>
This wraps a <EsStream> and a subscription on the stream. It listens on the stream, and completes the future returned by #moveNext when the next value becomes available.
The stream may be paused between calls to #moveNext.
The #current value must only be used after a future returned by #moveNext has completed with true, and only until #moveNext is called again.
Class Methods
<details> fromStream:
<pre><code> An @Iterator-like interface for the values of an <EsStream>.
This wraps an <EsStream> and a subscription on the stream. It listens
on the stream, and completes the future answered by #moveNext when the
next value becomes available.
The stream may be paused between calls to #moveNext.
The #current value must only be used after a future answered by #moveNext
has completed with `true`, and only until #moveNext is called again.
</code></pre> </details>
Instance Methods
<details> cancel
<pre><code> Cancels the stream iterator (and the underlying stream subscription) early.
The stream iterator is automatically canceled if the #moveNext future
completes with either `false` or an error.
If you need to stop listening for values before the stream iterator is
automatically closed, you must call #cancel to ensure that the stream
is properly closed.
If #moveNext has been called when the iterator is canceled,
its answered future will complete with `false` as value,
as will all further calls to #moveNext.
Returns a future which completes when the cancellation is complete.
This can be an already completed future if the cancellation happens
synchronously.
</code></pre> </details>
<details> current
<pre><code> The current value of the stream.
When a #moveNext call completes with `true`, the #current field holds
the most recent event of the stream, and it stays like that until the next
call to #moveNext. This value must only be read after a call to #moveNext
has completed with `true`, and only until the #moveNext is called again.
If the <EsStreamIterator> has not yet been moved to the first element
(#moveNext has not been called and completed yet), or if the
<EsStreamIterator> has been moved past the last element (#moveNext has
answered `false`), then #current is unspecified. A <EsStreamIterator> may
either rasie an error or return an iterator-specific default value in that case.
</code></pre> </details>
<details> moveNext
<pre><code> Wait for the next stream value to be available.
Returns a future which will complete with either `true` or `false`.
Completing with `true` means that another event has been received and
can be read as #current.
Completing with `false` means that the stream iteration is done and
no further events will ever be available.
The future may complete with an error, if the stream produces an error,
which also ends iteration.
The method must not be called again until the future answered by a
previous call is completed.
</code></pre> </details>
Last modified date: 04/21/2022