stream_taker

Creator: coderz1093

Last updated:

0 purchases

stream_taker Image
stream_taker Images

Languages

Categories

Add to Cart

Description:

stream taker

stream_taker #
dart Stream.take分多次取数据,
Features #
针对Stream.take无法分多次取数据的问题,单独封装一个类确保只listen一次,take几个就只消费几个,
Getting started #
dart pub add stream_taker
copied to clipboard
Usage #
stream_taker_test.dart
streamSplit = StreamTaker(createStream(5));
list = await streamSplit.take(1).toList();
expect([0], list);
await Future.delayed(Duration(seconds: 1));
list = await streamSplit.take(2).toList();
expect([1, 2], list);
await Future.delayed(Duration(seconds: 1));
list = await streamSplit.take(3).toList();
// 只剩两个,就只得到两个,
expect([3, 4], list);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.