Chromium Code Reviews| 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 // Core Stream types | 8 // Core Stream types |
| 9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
| 10 | 10 |
| (...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1161 * | 1161 * |
| 1162 * When you subscribe on a [Stream] using [Stream.listen], | 1162 * When you subscribe on a [Stream] using [Stream.listen], |
| 1163 * a [StreamSubscription] object is returned. This object | 1163 * a [StreamSubscription] object is returned. This object |
| 1164 * is used to later unsubscribe again, or to temporarily pause | 1164 * is used to later unsubscribe again, or to temporarily pause |
| 1165 * the stream's events. | 1165 * the stream's events. |
| 1166 */ | 1166 */ |
| 1167 abstract class StreamSubscription<T> { | 1167 abstract class StreamSubscription<T> { |
| 1168 /** | 1168 /** |
| 1169 * Cancels this subscription. It will no longer receive events. | 1169 * Cancels this subscription. It will no longer receive events. |
| 1170 * | 1170 * |
| 1171 * If an event is currently firing, this unsubscription will only | 1171 * Returns a future that completes when the stream is done cleaning up. |
| 1172 * take effect after all subscribers have received the current event. | 1172 * This can be used if the stream needs to release some resources |
| 1173 * | 1173 * that are needed for a following operation, |
| 1174 * Returns a future if the cancel-operation is not completed synchronously. | 1174 * for example a file being read, that should be deleted afterwards. |
| 1175 * Otherwise returns `null`. | 1175 * In that case, the file should not be deleted until the returned future |
|
Anders Johnsen
2014/04/29 09:46:01
[...], the file may not be deleted [...].
| |
| 1176 * has completed. | |
| 1177 * May return `null` if there is no need to wait. | |
|
Lasse Reichstein Nielsen
2014/04/29 09:17:53
Do we still return null?
Anders Johnsen
2014/04/29 09:46:01
Yes, sometimes
| |
| 1176 */ | 1178 */ |
| 1177 Future cancel(); | 1179 Future cancel(); |
| 1178 | 1180 |
| 1179 /** Set or override the data event handler of this subscription. */ | 1181 /** Set or override the data event handler of this subscription. */ |
| 1180 void onData(void handleData(T data)); | 1182 void onData(void handleData(T data)); |
| 1181 | 1183 |
| 1182 /** | 1184 /** |
| 1183 * Set or override the error event handler of this subscription. | 1185 * Set or override the error event handler of this subscription. |
| 1184 * | 1186 * |
| 1185 * This method overrides the handler that has been set at the invocation of | 1187 * This method overrides the handler that has been set at the invocation of |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1482 class _ControllerEventSinkWrapper<T> implements EventSink<T> { | 1484 class _ControllerEventSinkWrapper<T> implements EventSink<T> { |
| 1483 EventSink _sink; | 1485 EventSink _sink; |
| 1484 _ControllerEventSinkWrapper(this._sink); | 1486 _ControllerEventSinkWrapper(this._sink); |
| 1485 | 1487 |
| 1486 void add(T data) { _sink.add(data); } | 1488 void add(T data) { _sink.add(data); } |
| 1487 void addError(error, [StackTrace stackTrace]) { | 1489 void addError(error, [StackTrace stackTrace]) { |
| 1488 _sink.addError(error, stackTrace); | 1490 _sink.addError(error, stackTrace); |
| 1489 } | 1491 } |
| 1490 void close() { _sink.close(); } | 1492 void close() { _sink.close(); } |
| 1491 } | 1493 } |
| OLD | NEW |