Last active
August 29, 2015 14:18
-
-
Save zoechi/1c1273228c8ac6c0a5a1 to your computer and use it in GitHub Desktop.
SO 29320012 Do streams buffer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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