Skip to content

Instantly share code, notes, and snippets.

@zoechi
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoechi/1c1273228c8ac6c0a5a1 to your computer and use it in GitHub Desktop.
Save zoechi/1c1273228c8ac6c0a5a1 to your computer and use it in GitHub Desktop.
SO 29320012 Do streams buffer
import 'dart:async';
Stream<int> a() async* {
for (int i = 1; i <= 10; ++i) {
print('yield $i');
yield i;
}
}
main() {
// a().listen((e) async {
// await new Future.delayed(const Duration(seconds: 1));
// print('a: $e');
// });
StreamSubscription sub;
sub = a().listen((e) async {
sub.pause();
await new Future.delayed(const Duration(seconds: 1));
print('b: $e');
sub.resume();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment