dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.06k stars 1.56k forks source link

StreamController.addFuture #16187

Open blois opened 10 years ago

blois commented 10 years ago

Would be nice if StreamController had an addFuture method which added the result of the future once the future completed, or an error if the future errors out. Folks don't always remember to handle the error case.

In addition, it would be great if StreamController had a constructor from a list of Futures which essentially did the same thing.

lrhn commented 10 years ago

Removed Type-Defect label. Added Type-Enhancement, Library-Async labels.

lrhn commented 10 years ago

We already have the StreamController.addStream, so it should be possible to do something similar with a future - it'll be impossible to add anything else while the future is waiting.

For the constructor, it sounds more like a Stream constuctor, liek Stream.fromFutures. There are two alternatives (values in the order of the list, or in the order they comlpete).