| Index: pkg/barback/lib/src/utils.dart
|
| diff --git a/pkg/barback/lib/src/utils.dart b/pkg/barback/lib/src/utils.dart
|
| index 0a41c8ed08a5935f0dd67ee31e1c19ce948e2c1a..37816bcfe8120bee4732c7b8070f303ccc8dff87 100644
|
| --- a/pkg/barback/lib/src/utils.dart
|
| +++ b/pkg/barback/lib/src/utils.dart
|
| @@ -179,3 +179,20 @@ Future pumpEventQueue([int times=20]) {
|
| /// Like [new Future], but avoids issue 11911 by using [new Future.value] under
|
| /// the covers.
|
| Future newFuture(callback()) => new Future.value().then((_) => callback());
|
| +
|
| +/// Returns a buffered stream that will emit the same values as the stream
|
| +/// returned by [future] once [future] completes. If [future] completes to an
|
| +/// error, the return value will emit that error and then close.
|
| +Stream futureStream(Future<Stream> future) {
|
| + var controller = new StreamController(sync: true);
|
| + future.then((stream) {
|
| + stream.listen(
|
| + controller.add,
|
| + onError: (error) => controller.addError(error),
|
| + onDone: controller.close);
|
| + }).catchError((e) {
|
| + controller.addError(e);
|
| + controller.close();
|
| + });
|
| + return controller.stream;
|
| +}
|
|
|