| Index: lib/src/two_way_stream.dart
|
| diff --git a/lib/src/two_way_stream.dart b/lib/src/two_way_stream.dart
|
| index 5914173876f6d21799bfdcc1c34cd45471c71852..f2d5b5eb6929ab8c46ea405bd94a45984fc38e51 100644
|
| --- a/lib/src/two_way_stream.dart
|
| +++ b/lib/src/two_way_stream.dart
|
| @@ -38,6 +38,9 @@ class TwoWayStream {
|
| Future get done => _doneCompleter.future;
|
| final _doneCompleter = new Completer();
|
|
|
| + /// Whether the stream has been closed.
|
| + bool get isClosed => _doneCompleter.isCompleted;
|
| +
|
| /// Creates a two-way stream.
|
| ///
|
| /// [input] and [output] should emit and take (respectively) JSON-encoded
|
| @@ -103,12 +106,12 @@ class TwoWayStream {
|
| _inputSubscription = _input.listen(handleInput,
|
| onError: (error, stackTrace) {
|
| if (_doneCompleter.isCompleted) return;
|
| - _output.close();
|
| _doneCompleter.completeError(error, stackTrace);
|
| + _output.close();
|
| }, onDone: () {
|
| if (_doneCompleter.isCompleted) return;
|
| - _output.close();
|
| _doneCompleter.complete();
|
| + _output.close();
|
| }, cancelOnError: true);
|
|
|
| return _doneCompleter.future;
|
| @@ -123,6 +126,7 @@ class TwoWayStream {
|
| throw new StateError("Can't call $_name.close before $_name.listen.");
|
| }
|
|
|
| + _isClosed = true;
|
| if (!_doneCompleter.isCompleted) _doneCompleter.complete();
|
|
|
| var inputFuture = _inputSubscription.cancel();
|
|
|