| 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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 if (_controller == null) { | 748 if (_controller == null) { |
| 749 // Return a dummy subscription backed by nothing, since | 749 // Return a dummy subscription backed by nothing, since |
| 750 // it won't ever receive any events. | 750 // it won't ever receive any events. |
| 751 return new _DummyStreamSubscription<T>(); | 751 return new _DummyStreamSubscription<T>(); |
| 752 } | 752 } |
| 753 if (_subscription == null) { | 753 if (_subscription == null) { |
| 754 _subscription = _source.listen(_controller.add, | 754 _subscription = _source.listen(_controller.add, |
| 755 onError: _controller.addError, | 755 onError: _controller.addError, |
| 756 onDone: _controller.close); | 756 onDone: _controller.close); |
| 757 } | 757 } |
| 758 return _controller.stream.listen(onData, onError: onError, onDone: onDone, | 758 if (onData == null) onData = _nullDataHandler; |
| 759 cancelOnError: cancelOnError); | 759 if (onError == null) onError = _nullErrorHandler; |
| 760 if (onDone == null) onDone = _nullDoneHandler; |
| 761 cancelOnError = identical(true, cancelOnError); |
| 762 return _controller._subscribe(onData, onError, onDone, cancelOnError); |
| 760 } | 763 } |
| 761 | 764 |
| 762 void _onCancel() { | 765 void _onCancel() { |
| 763 bool shutdown = (_controller == null) || _controller.isClosed; | 766 bool shutdown = (_controller == null) || _controller.isClosed; |
| 764 if (_onCancelHandler != null) { | 767 if (_onCancelHandler != null) { |
| 765 _zone.executePeriodicCallbackGuarded( | 768 _zone.executePeriodicCallbackGuarded( |
| 766 () => _onCancelHandler(new _BroadcastSubscriptionWrapper(this))); | 769 () => _onCancelHandler(new _BroadcastSubscriptionWrapper(this))); |
| 767 } | 770 } |
| 768 if (shutdown) { | 771 if (shutdown) { |
| 769 if (_subscription != null) { | 772 if (_subscription != null) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 _FutureImpl<bool> hasNext = _futureOrPrefetch; | 1002 _FutureImpl<bool> hasNext = _futureOrPrefetch; |
| 1000 _clear(); | 1003 _clear(); |
| 1001 hasNext._setValue(false); | 1004 hasNext._setValue(false); |
| 1002 return; | 1005 return; |
| 1003 } | 1006 } |
| 1004 _subscription.pause(); | 1007 _subscription.pause(); |
| 1005 _futureOrPrefetch = null; | 1008 _futureOrPrefetch = null; |
| 1006 _state = _STATE_EXTRA_DONE; | 1009 _state = _STATE_EXTRA_DONE; |
| 1007 } | 1010 } |
| 1008 } | 1011 } |
| OLD | NEW |