int count
) Provides at most the first n
values of this stream.
Forwards the first n
data events of this stream, and all error
events, to the returned stream, and ends with a done event.
If this stream produces fewer than count
values before it's done,
so will the returned stream.
Stops listening to the stream after the first n
elements have been
received.
Internally the method cancels its subscription after these elements. This means that single-subscription (non-broadcast) streams are closed and cannot be reused after a call to this method.
The returned stream is a broadcast stream if this stream is. For a broadcast stream, the events are only counted from the time the returned stream is listened to.
Source
/**
* Provides at most the first [n] values of this stream.
*
* Forwards the first [n] data events of this stream, and all error
* events, to the returned stream, and ends with a done event.
*
* If this stream produces fewer than [count] values before it's done,
* so will the returned stream.
*
* Stops listening to the stream after the first [n] elements have been
* received.
*
* Internally the method cancels its subscription after these elements. This
* means that single-subscription (non-broadcast) streams are closed and
* cannot be reused after a call to this method.
*
* The returned stream is a broadcast stream if this stream is.
* For a broadcast stream, the events are only counted from the time
* the returned stream is listened to.
*/
Stream<T> take(int count) {
return new _TakeStream(this, count);
}