| 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 /** | 7 /** |
| 8 * Utility function to attach a stack trace to an [error] if it doesn't have | 8 * Utility function to attach a stack trace to an [error] if it doesn't have |
| 9 * one already. | 9 * one already. |
| 10 */ | 10 */ |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 void _onCancel() { | 133 void _onCancel() { |
| 134 if (_subscription != null) { | 134 if (_subscription != null) { |
| 135 StreamSubscription subscription = _subscription; | 135 StreamSubscription subscription = _subscription; |
| 136 _subscription = null; | 136 _subscription = null; |
| 137 subscription.cancel(); | 137 subscription.cancel(); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 // Methods used as listener on source subscription. | 141 // Methods used as listener on source subscription. |
| 142 | 142 |
| 143 // TODO(ahe): Restore type when feature is implemented in dart2js | 143 void _handleData(S data) { |
| 144 // checked mode. http://dartbug.com/7733 | |
| 145 void _handleData(/*S*/ data) { | |
| 146 _stream._handleData(data, this); | 144 _stream._handleData(data, this); |
| 147 } | 145 } |
| 148 | 146 |
| 149 void _handleError(error) { | 147 void _handleError(error) { |
| 150 _stream._handleError(error, this); | 148 _stream._handleError(error, this); |
| 151 } | 149 } |
| 152 | 150 |
| 153 void _handleDone() { | 151 void _handleDone() { |
| 154 _stream._handleDone(this); | 152 _stream._handleDone(this); |
| 155 } | 153 } |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 * A [StreamTransformer] that modifies stream events. | 422 * A [StreamTransformer] that modifies stream events. |
| 425 * | 423 * |
| 426 * This class is used by [StreamTransformer]'s factory constructor. | 424 * This class is used by [StreamTransformer]'s factory constructor. |
| 427 * It is actually an [StreamEventTransformer] where the functions used to | 425 * It is actually an [StreamEventTransformer] where the functions used to |
| 428 * modify the events are passed as constructor arguments. | 426 * modify the events are passed as constructor arguments. |
| 429 * | 427 * |
| 430 * If an argument is omitted, it acts as the default method from | 428 * If an argument is omitted, it acts as the default method from |
| 431 * [StreamEventTransformer]. | 429 * [StreamEventTransformer]. |
| 432 */ | 430 */ |
| 433 class _StreamTransformerImpl<S, T> extends StreamEventTransformer<S, T> { | 431 class _StreamTransformerImpl<S, T> extends StreamEventTransformer<S, T> { |
| 434 // TODO(ahe): Restore type when feature is implemented in dart2js | 432 final _TransformDataHandler<S, T> _handleData; |
| 435 // checked mode. http://dartbug.com/7733 | |
| 436 final Function /*_TransformDataHandler<S, T>*/ _handleData; | |
| 437 final _TransformErrorHandler<T> _handleError; | 433 final _TransformErrorHandler<T> _handleError; |
| 438 final _TransformDoneHandler<T> _handleDone; | 434 final _TransformDoneHandler<T> _handleDone; |
| 439 | 435 |
| 440 _StreamTransformerImpl(void handleData(S data, EventSink<T> sink), | 436 _StreamTransformerImpl(void handleData(S data, EventSink<T> sink), |
| 441 void handleError(data, EventSink<T> sink), | 437 void handleError(data, EventSink<T> sink), |
| 442 void handleDone(EventSink<T> sink)) | 438 void handleDone(EventSink<T> sink)) |
| 443 : this._handleData = (handleData == null ? _defaultHandleData | 439 : this._handleData = (handleData == null ? _defaultHandleData |
| 444 : handleData), | 440 : handleData), |
| 445 this._handleError = (handleError == null ? _defaultHandleError | 441 this._handleError = (handleError == null ? _defaultHandleError |
| 446 : handleError), | 442 : handleError), |
| 447 this._handleDone = (handleDone == null ? _defaultHandleDone | 443 this._handleDone = (handleDone == null ? _defaultHandleDone |
| 448 : handleDone); | 444 : handleDone); |
| 449 | 445 |
| 450 void handleData(S data, EventSink<T> sink) { | 446 void handleData(S data, EventSink<T> sink) { |
| 451 _handleData(data, sink); | 447 _handleData(data, sink); |
| 452 } | 448 } |
| 453 | 449 |
| 454 void handleError(error, EventSink<T> sink) { | 450 void handleError(error, EventSink<T> sink) { |
| 455 _handleError(error, sink); | 451 _handleError(error, sink); |
| 456 } | 452 } |
| 457 | 453 |
| 458 void handleDone(EventSink<T> sink) { | 454 void handleDone(EventSink<T> sink) { |
| 459 _handleDone(sink); | 455 _handleDone(sink); |
| 460 } | 456 } |
| 461 } | 457 } |
| 462 | 458 |
| OLD | NEW |