OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library async.stream_events; | 5 library async.stream_events; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import "subscription_stream.dart"; | 10 import "subscription_stream.dart"; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 throw _failClosed(); | 216 throw _failClosed(); |
217 } | 217 } |
218 | 218 |
219 /// Cancels the underlying stream subscription. | 219 /// Cancels the underlying stream subscription. |
220 /// | 220 /// |
221 /// If [immediate] is `false` (the default), the cancel operation waits until | 221 /// If [immediate] is `false` (the default), the cancel operation waits until |
222 /// all previously requested events have been processed, then it cancels the | 222 /// all previously requested events have been processed, then it cancels the |
223 /// subscription providing the events. | 223 /// subscription providing the events. |
224 /// | 224 /// |
225 /// If [immediate] is `true`, the subscription is instead canceled | 225 /// If [immediate] is `true`, the subscription is instead canceled |
226 /// immediately. Any pending events are completed as though the underlying | 226 /// immediately. Any pending events complete with a 'closed'-event, as though |
227 /// stream had closed. | 227 /// the stream had closed by itself. |
228 /// | 228 /// |
229 /// The returned future completes with the result of calling | 229 /// The returned future completes with the result of calling |
230 /// `cancel`. | 230 /// `cancel`. |
231 /// | 231 /// |
232 /// After calling `cancel`, no further events can be requested. | 232 /// After calling `cancel`, no further events can be requested. |
233 /// None of [next], [rest], [skip], [take] or [cancel] may be | 233 /// None of [next], [rest], [skip], [take] or [cancel] may be |
234 /// called again. | 234 /// called again. |
235 Future cancel({bool immediate: false}) { | 235 Future cancel({bool immediate: false}) { |
236 if (_isClosed) throw _failClosed(); | 236 if (_isClosed) throw _failClosed(); |
237 _isClosed = true; | 237 _isClosed = true; |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 _completer.complete(true); | 621 _completer.complete(true); |
622 return true; | 622 return true; |
623 } | 623 } |
624 return false; | 624 return false; |
625 } | 625 } |
626 | 626 |
627 void close(_) { | 627 void close(_) { |
628 _completer.complete(false); | 628 _completer.complete(false); |
629 } | 629 } |
630 } | 630 } |
OLD | NEW |