take method
Requests the next count
data events as a list.
The count
must be non-negative.
Equivalent to calling next count
times and
storing the data values in a list.
If an error occurs before count
data events has
been collected, the returned future completes with
that error instead.
If the stream closes before count
data events,
the returned future completes with the list
of data collected so far. That is, the returned
list may have fewer than count
elements.
Implementation
Future<List<T>> take(int count) {
if (count < 0) throw new RangeError.range(count, 0, null, "count");
if (!_isClosed) {
var request = new _TakeRequest<T>(count);
_addRequest(request);
return request.future;
}
throw _failClosed();
}