Skip to content

Instantly share code, notes, and snippets.

@Bringoff
Created March 19, 2021 20:54
Show Gist options
  • Select an option

  • Save Bringoff/aa6c030456c30cb846c34a228ecfe68e to your computer and use it in GitHub Desktop.

Select an option

Save Bringoff/aa6c030456c30cb846c34a228ecfe68e to your computer and use it in GitHub Desktop.
Parallel streams
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