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, StackTrace stackTrace); | 10 void _addError(Object error, StackTrace stackTrace); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 void onData(void handleData(T event)) { | 139 void onData(void handleData(T event)) { |
140 if (handleData == null) handleData = _nullDataHandler; | 140 if (handleData == null) handleData = _nullDataHandler; |
141 // TODO(floitsch): the return type should be 'void', and the type | 141 // TODO(floitsch): the return type should be 'void', and the type |
142 // should be inferred. | 142 // should be inferred. |
143 _onData = _zone.registerUnaryCallback/*<dynamic, T>*/(handleData); | 143 _onData = _zone.registerUnaryCallback/*<dynamic, T>*/(handleData); |
144 } | 144 } |
145 | 145 |
146 void onError(Function handleError) { | 146 void onError(Function handleError) { |
147 if (handleError == null) handleError = _nullErrorHandler; | 147 if (handleError == null) handleError = _nullErrorHandler; |
148 _onError = _registerErrorHandler/*<T>*/(handleError, _zone); | 148 // We are not allowed to use 'void' as type argument for the generic type, |
| 149 // so we use 'dynamic' instead. |
| 150 _onError = _registerErrorHandler/*<dynamic>*/(handleError, _zone); |
149 } | 151 } |
150 | 152 |
151 void onDone(void handleDone()) { | 153 void onDone(void handleDone()) { |
152 if (handleDone == null) handleDone = _nullDoneHandler; | 154 if (handleDone == null) handleDone = _nullDoneHandler; |
153 _onDone = _zone.registerCallback(handleDone); | 155 _onDone = _zone.registerCallback(handleDone); |
154 } | 156 } |
155 | 157 |
156 void pause([Future resumeSignal]) { | 158 void pause([Future resumeSignal]) { |
157 if (_isCanceled) return; | 159 if (_isCanceled) return; |
158 bool wasPaused = _isPaused; | 160 bool wasPaused = _isPaused; |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 class _EmptyStream<T> extends Stream<T> { | 1089 class _EmptyStream<T> extends Stream<T> { |
1088 const _EmptyStream() : super._internal(); | 1090 const _EmptyStream() : super._internal(); |
1089 bool get isBroadcast => true; | 1091 bool get isBroadcast => true; |
1090 StreamSubscription<T> listen(void onData(T data), | 1092 StreamSubscription<T> listen(void onData(T data), |
1091 {Function onError, | 1093 {Function onError, |
1092 void onDone(), | 1094 void onDone(), |
1093 bool cancelOnError}) { | 1095 bool cancelOnError}) { |
1094 return new _DoneStreamSubscription<T>(onDone); | 1096 return new _DoneStreamSubscription<T>(onDone); |
1095 } | 1097 } |
1096 } | 1098 } |
OLD | NEW |