Chromium Code Reviews| 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 /** Utility function to create an [AsyncError] if [error] isn't one already. */ | 7 /** Utility function to create an [AsyncError] if [error] isn't one already. */ |
| 8 AsyncError _asyncError(Object error, Object stackTrace, [AsyncError cause]) { | 8 AsyncError _asyncError(Object error, Object stackTrace, [AsyncError cause]) { |
| 9 if (error is AsyncError) return error; | 9 if (error is AsyncError) return error; |
| 10 if (cause == null) return new AsyncError(error, stackTrace); | 10 if (cause == null) return new AsyncError(error, stackTrace); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 * A stream transformer that intercepts all events and can generate any event as | 552 * A stream transformer that intercepts all events and can generate any event as |
| 553 * output. | 553 * output. |
| 554 * | 554 * |
| 555 * Each incoming event on the source stream is passed to the corresponding | 555 * Each incoming event on the source stream is passed to the corresponding |
| 556 * provided event handler, along with a [StreamSink] linked to the output | 556 * provided event handler, along with a [StreamSink] linked to the output |
| 557 * Stream. | 557 * Stream. |
| 558 * The handler can then decide exactly which events to send to the output. | 558 * The handler can then decide exactly which events to send to the output. |
| 559 */ | 559 */ |
| 560 class _StreamEventTransformerImpl<S, T> | 560 class _StreamEventTransformerImpl<S, T> |
| 561 implements StreamEventTransformer<S, T> { | 561 implements StreamEventTransformer<S, T> { |
| 562 final _TransformDataHandler<S, T> _handleData; | 562 // TODO(ahe): Restore type when feature is implemented in dart2js |
|
ahe
2013/01/29 11:00:23
I'm not sure why this TODO has my name on it?
| |
| 563 // checked mode. http://dartbug.com/7733 | |
| 564 final Function /*_TransformDataHandler<S, T>*/ _handleData; | |
| 563 final _TransformErrorHandler<T> _handleError; | 565 final _TransformErrorHandler<T> _handleError; |
| 564 final _TransformDoneHandler<T> _handleDone; | 566 final _TransformDoneHandler<T> _handleDone; |
| 565 | 567 |
| 566 _StreamEventTransformerImpl(void onData(S data, StreamSink<T> sink), | 568 _StreamEventTransformerImpl(void onData(S data, StreamSink<T> sink), |
| 567 void onError(AsyncError data, StreamSink<T> sink), | 569 void onError(AsyncError data, StreamSink<T> sink), |
| 568 void onDone(StreamSink<T> sink)) | 570 void onDone(StreamSink<T> sink)) |
| 569 : this._handleData = (onData == null ? _defaultHandleData : onData), | 571 : this._handleData = (onData == null ? _defaultHandleData : onData), |
| 570 this._handleError = (onError == null ? _defaultHandleError : onError), | 572 this._handleError = (onError == null ? _defaultHandleError : onError), |
| 571 this._handleDone = (onDone == null ? _defaultHandleDone : onDone); | 573 this._handleDone = (onDone == null ? _defaultHandleDone : onDone); |
| 572 | 574 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 587 } | 589 } |
| 588 | 590 |
| 589 void handleDone(StreamSink<T> sink) { | 591 void handleDone(StreamSink<T> sink) { |
| 590 try { | 592 try { |
| 591 _handleDone(sink); | 593 _handleDone(sink); |
| 592 } catch (e, s) { | 594 } catch (e, s) { |
| 593 sink.signalError(_asyncError(e, s)); | 595 sink.signalError(_asyncError(e, s)); |
| 594 } | 596 } |
| 595 } | 597 } |
| 596 } | 598 } |
| OLD | NEW |