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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 _subscription = null; | 108 _subscription = null; |
109 subscription.cancel(); | 109 subscription.cancel(); |
110 } | 110 } |
111 return null; | 111 return null; |
112 } | 112 } |
113 | 113 |
114 void _handleData(S data) { | 114 void _handleData(S data) { |
115 try { | 115 try { |
116 _transformerSink.add(data); | 116 _transformerSink.add(data); |
117 } catch (e, s) { | 117 } catch (e, s) { |
118 _addError(_asyncError(e, s), s); | 118 _addError(e, s); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 void _handleError(error, [stackTrace]) { | 122 void _handleError(error, [stackTrace]) { |
123 try { | 123 try { |
124 _transformerSink.addError(error, stackTrace); | 124 _transformerSink.addError(error, stackTrace); |
125 } catch (e, s) { | 125 } catch (e, s) { |
126 if (identical(e, error)) { | 126 if (identical(e, error)) { |
127 _addError(error, stackTrace); | 127 _addError(error, stackTrace); |
128 } else { | 128 } else { |
129 _addError(_asyncError(e, s), s); | 129 _addError(e, s); |
130 } | 130 } |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 void _handleDone() { | 134 void _handleDone() { |
135 try { | 135 try { |
136 _subscription = null; | 136 _subscription = null; |
137 _transformerSink.close(); | 137 _transformerSink.close(); |
138 } catch (e, s) { | 138 } catch (e, s) { |
139 _addError(_asyncError(e, s), s); | 139 _addError(e, s); |
140 } | 140 } |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 | 144 |
145 typedef EventSink<S> _SinkMapper<S, T>(EventSink<T> output); | 145 typedef EventSink<S> _SinkMapper<S, T>(EventSink<T> output); |
146 | 146 |
147 /** | 147 /** |
148 * A StreamTransformer for Sink-mappers. | 148 * A StreamTransformer for Sink-mappers. |
149 * | 149 * |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 void onDone(), | 306 void onDone(), |
307 bool cancelOnError }) { | 307 bool cancelOnError }) { |
308 cancelOnError = identical(true, cancelOnError); | 308 cancelOnError = identical(true, cancelOnError); |
309 StreamSubscription<T> result = _transformer(_stream, cancelOnError); | 309 StreamSubscription<T> result = _transformer(_stream, cancelOnError); |
310 result.onData(onData); | 310 result.onData(onData); |
311 result.onError(onError); | 311 result.onError(onError); |
312 result.onDone(onDone); | 312 result.onDone(onDone); |
313 return result; | 313 return result; |
314 } | 314 } |
315 } | 315 } |
OLD | NEW |