| Index: pkg/barback/lib/src/utils.dart
|
| diff --git a/pkg/barback/lib/src/utils.dart b/pkg/barback/lib/src/utils.dart
|
| index 53ef822079eeb3e385393454d46c9281ffb96183..38a596eaa0f7bd5da1acd6ccb636b9c796db841d 100644
|
| --- a/pkg/barback/lib/src/utils.dart
|
| +++ b/pkg/barback/lib/src/utils.dart
|
| @@ -196,3 +196,22 @@ Stream futureStream(Future<Stream> future) {
|
| });
|
| return controller.stream;
|
| }
|
| +
|
| +/// Returns a [Stream] that will emit the same values as the stream returned by
|
| +/// [callback].
|
| +///
|
| +/// [callback] will only be called when the returned [Stream] gets a subscriber.
|
| +Stream callbackStream(Stream callback()) {
|
| + var subscription;
|
| + var controller;
|
| + controller = new StreamController(onListen: () {
|
| + subscription = callback().listen(controller.add,
|
| + onError: controller.addError,
|
| + onDone: controller.close);
|
| + },
|
| + onCancel: () => subscription.cancel(),
|
| + onPause: () => subscription.pause(),
|
| + onResume: () => subscription.resume(),
|
| + sync: true);
|
| + return controller.stream;
|
| +}
|
|
|