| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.async; | 5 part of dart.async; |
| 6 | 6 |
| 7 /** Abstract and private interface for a place to put events. */ | 7 /** Abstract and private interface for a place to put events. */ |
| 8 abstract class _EventSink<T> { | 8 abstract class _EventSink<T> { |
| 9 void _add(T data); | 9 void _add(T data); |
| 10 void _addError(Object error); | 10 void _addError(Object error); |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 void onDone(), | 712 void onDone(), |
| 713 bool cancelOnError}) { | 713 bool cancelOnError}) { |
| 714 if (_controller == null) { | 714 if (_controller == null) { |
| 715 throw new StateError("Source stream has been closed."); | 715 throw new StateError("Source stream has been closed."); |
| 716 } | 716 } |
| 717 if (_subscription == null) { | 717 if (_subscription == null) { |
| 718 _subscription = _source.listen(_controller.add, | 718 _subscription = _source.listen(_controller.add, |
| 719 onError: _controller.addError, | 719 onError: _controller.addError, |
| 720 onDone: _controller.close); | 720 onDone: _controller.close); |
| 721 } | 721 } |
| 722 return _controller.stream.listen(onData, onError: onError, onDone: onDone, | 722 if (onData == null) onData = _nullDataHandler; |
| 723 cancelOnError: cancelOnError); | 723 if (onError == null) onError = _nullErrorHandler; |
| 724 if (onDone == null) onDone = _nullDoneHandler; |
| 725 cancelOnError = identical(true, cancelOnError); |
| 726 return _controller._subscribe(onData, onError, onDone, cancelOnError); |
| 724 } | 727 } |
| 725 | 728 |
| 726 void _onCancel() { | 729 void _onCancel() { |
| 727 // Called by [_controller] when it has no subscribers left. | 730 // Called by [_controller] when it has no subscribers left. |
| 728 StreamSubscription subscription = _subscription; | 731 StreamSubscription subscription = _subscription; |
| 729 _subscription = null; | 732 _subscription = null; |
| 730 _controller = null; // Marks the stream as no longer listenable. | 733 _controller = null; // Marks the stream as no longer listenable. |
| 731 subscription.cancel(); | 734 subscription.cancel(); |
| 732 } | 735 } |
| 733 } | 736 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 _FutureImpl<bool> hasNext = _futureOrPrefetch; | 878 _FutureImpl<bool> hasNext = _futureOrPrefetch; |
| 876 _clear(); | 879 _clear(); |
| 877 hasNext._setValue(false); | 880 hasNext._setValue(false); |
| 878 return; | 881 return; |
| 879 } | 882 } |
| 880 _subscription.pause(); | 883 _subscription.pause(); |
| 881 _futureOrPrefetch = null; | 884 _futureOrPrefetch = null; |
| 882 _state = _STATE_EXTRA_DONE; | 885 _state = _STATE_EXTRA_DONE; |
| 883 } | 886 } |
| 884 } | 887 } |
| OLD | NEW |