Created
March 19, 2021 20:54
-
-
Save Bringoff/aa6c030456c30cb846c34a228ecfe68e to your computer and use it in GitHub Desktop.
Parallel streams
This file contains hidden or 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
| void main() async { | |
| upload(1).listen((event) {}); | |
| await Future.delayed(Duration(seconds: 1)); | |
| upload(2).listen((event) {}); | |
| await Future.delayed(Duration(seconds: 1)); | |
| upload(3).listen((event) {}); | |
| await Future.delayed(Duration(seconds: 1)); | |
| upload(4).listen((event) {}); | |
| await Future.delayed(Duration(seconds: 1)); | |
| upload(5).listen((event) {}); | |
| await Future.delayed(Duration(seconds: 1)); | |
| upload(6).listen((event) {}); | |
| } | |
| Stream<void> upload(int order) async* { | |
| for (var i = 0; i < 1000; i++) { | |
| print('$order order $i before'); | |
| await Future.delayed(Duration(seconds: 1)); | |
| print('$order order $i after'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment