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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 263 |
264 /// A closure mapping a stream and cancelOnError to a StreamSubscription. | 264 /// A closure mapping a stream and cancelOnError to a StreamSubscription. |
265 typedef StreamSubscription<T> _SubscriptionTransformer<S, T>( | 265 typedef StreamSubscription<T> _SubscriptionTransformer<S, T>( |
266 Stream<S> stream, bool cancelOnError); | 266 Stream<S> stream, bool cancelOnError); |
267 | 267 |
268 /** | 268 /** |
269 * A [StreamTransformer] that minimizes the number of additional classes. | 269 * A [StreamTransformer] that minimizes the number of additional classes. |
270 * | 270 * |
271 * Instead of implementing three classes: a [StreamTransformer], a [Stream] | 271 * Instead of implementing three classes: a [StreamTransformer], a [Stream] |
272 * (as the result of a `bind` call) and a [StreamSubscription] (which does the | 272 * (as the result of a `bind` call) and a [StreamSubscription] (which does the |
273 * actual work), this class only requires a fincution that is invoked when the | 273 * actual work), this class only requires a function that is invoked when the |
274 * last bit (the subscription) of the transformer-workflow is needed. | 274 * last bit (the subscription) of the transformer-workflow is needed. |
275 * | 275 * |
276 * The given transformer function maps from Stream and cancelOnError to a | 276 * The given transformer function maps from Stream and cancelOnError to a |
277 * `StreamSubscription`. As such it can also act on `cancel` events, making it | 277 * `StreamSubscription`. As such it can also act on `cancel` events, making it |
278 * fully general. | 278 * fully general. |
279 */ | 279 */ |
280 class _StreamSubscriptionTransformer<S, T> implements StreamTransformer<S, T> { | 280 class _StreamSubscriptionTransformer<S, T> implements StreamTransformer<S, T> { |
281 final _SubscriptionTransformer<S, T> _transformer; | 281 final _SubscriptionTransformer<S, T> _transformer; |
282 | 282 |
283 const _StreamSubscriptionTransformer(this._transformer); | 283 const _StreamSubscriptionTransformer(this._transformer); |
(...skipping 20 matching lines...) Expand all Loading... |
304 void onDone(), | 304 void onDone(), |
305 bool cancelOnError }) { | 305 bool cancelOnError }) { |
306 cancelOnError = identical(true, cancelOnError); | 306 cancelOnError = identical(true, cancelOnError); |
307 StreamSubscription<T> result = _transformer(_stream, cancelOnError); | 307 StreamSubscription<T> result = _transformer(_stream, cancelOnError); |
308 result.onData(onData); | 308 result.onData(onData); |
309 result.onError(onError); | 309 result.onError(onError); |
310 result.onDone(onDone); | 310 result.onDone(onDone); |
311 return result; | 311 return result; |
312 } | 312 } |
313 } | 313 } |
OLD | NEW |