danschultz / stream_transformers

A Dart package for transforming streams
MIT License
12 stars 9 forks source link

Add BufferPeriod #18

Open danschultz opened 9 years ago

danschultz commented 9 years ago

Buffers the events in a stream for each interval period. The transformed stream will contain a list of the buffered events for each period.

var source = new Stream.periodic(new Duration(seconds: 1), (i) => i);
var buffered = source.transform(new BufferPeriod(new Duration(seconds: 3))).take(2);
buffered.listen((value) => print("Next: $value"));

// Next: [1, 2, 3]
// Next: [4, 5, 6]