OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 7 /** |
8 * Wraps an [_EventSink] so it exposes only the [EventSink] interface. | 8 * Wraps an [_EventSink] so it exposes only the [EventSink] interface. |
9 */ | 9 */ |
10 class _EventSinkWrapper<T> implements EventSink<T> { | 10 class _EventSinkWrapper<T> implements EventSink<T> { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 243 } |
244 | 244 |
245 /** Default data handler forwards all data. */ | 245 /** Default data handler forwards all data. */ |
246 static void _defaultHandleData(var data, EventSink sink) { | 246 static void _defaultHandleData(var data, EventSink sink) { |
247 sink.add(data); | 247 sink.add(data); |
248 } | 248 } |
249 | 249 |
250 /** Default error handler forwards all errors. */ | 250 /** Default error handler forwards all errors. */ |
251 static void _defaultHandleError(error, StackTrace stackTrace, | 251 static void _defaultHandleError(error, StackTrace stackTrace, |
252 EventSink sink) { | 252 EventSink sink) { |
253 sink.addError(error); | 253 sink.addError(error, stackTrace); |
254 } | 254 } |
255 | 255 |
256 /** Default done handler forwards done. */ | 256 /** Default done handler forwards done. */ |
257 static void _defaultHandleDone(EventSink sink) { | 257 static void _defaultHandleDone(EventSink sink) { |
258 sink.close(); | 258 sink.close(); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 /// A closure mapping a stream and cancelOnError to a StreamSubscription. | 262 /// A closure mapping a stream and cancelOnError to a StreamSubscription. |
263 typedef StreamSubscription<T> _SubscriptionTransformer<S, T>( | 263 typedef StreamSubscription<T> _SubscriptionTransformer<S, T>( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 void onDone(), | 302 void onDone(), |
303 bool cancelOnError }) { | 303 bool cancelOnError }) { |
304 cancelOnError = identical(true, cancelOnError); | 304 cancelOnError = identical(true, cancelOnError); |
305 StreamSubscription<T> result = _transformer(_stream, cancelOnError); | 305 StreamSubscription<T> result = _transformer(_stream, cancelOnError); |
306 result.onData(onData); | 306 result.onData(onData); |
307 result.onError(onError); | 307 result.onError(onError); |
308 result.onDone(onDone); | 308 result.onDone(onDone); |
309 return result; | 309 return result; |
310 } | 310 } |
311 } | 311 } |
OLD | NEW |