| Index: lib/src/utils.dart
|
| diff --git a/lib/src/utils.dart b/lib/src/utils.dart
|
| index 27d56b438f12b1052104df8f117bb0165d641982..7fb513dcaa9a68fca2312e1a870db8cf86203680 100644
|
| --- a/lib/src/utils.dart
|
| +++ b/lib/src/utils.dart
|
| @@ -598,6 +598,25 @@ Stream mergeStreams(Stream stream1, Stream stream2) {
|
| 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;
|
| +}
|
| +
|
| /// A regular expression matching a trailing CR character.
|
| final _trailingCR = new RegExp(r"\r$");
|
|
|
|
|