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_group; | 5 library async.stream_group; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 /// A collection of streams whose events are unified and sent through a central | 9 /// A collection of streams whose events are unified and sent through a central |
10 /// stream. | 10 /// stream. |
11 /// | 11 /// |
12 /// Both errors and data events are forwarded through [stream]. The streams in | 12 /// Both errors and data events are forwarded through [stream]. The streams in |
13 /// the group won't be listened to until [stream] has a listener. **Note that | 13 /// the group won't be listened to until [stream] has a listener. **Note that |
14 /// this means that events emitted by broadcast streams will be dropped until | 14 /// this means that events emitted by broadcast streams will be dropped until |
15 /// [stream] has a listener.** | 15 /// [stream] has a listener.** |
16 /// | 16 /// |
17 /// If the `StreamGroup` is construced using [new StreamGroup], [stream] will be | 17 /// If the `StreamGroup` is constructed using [new StreamGroup], [stream] will b
e |
18 /// single-subscription. In this case, if [stream] is paused or canceled, all | 18 /// single-subscription. In this case, if [stream] is paused or canceled, all |
19 /// streams in the group will likewise be paused or canceled, respectively. | 19 /// streams in the group will likewise be paused or canceled, respectively. |
20 /// | 20 /// |
21 /// If the `StreamGroup` is construced using [new StreamGroup.broadcast], | 21 /// If the `StreamGroup` is constructed using [new StreamGroup.broadcast], |
22 /// [stream] will be a broadcast stream. In this case, the streams in the group | 22 /// [stream] will be a broadcast stream. In this case, the streams in the group |
23 /// will never be paused and single-subscription streams in the group will never | 23 /// will never be paused and single-subscription streams in the group will never |
24 /// be canceled. **Note that single-subscription streams in a broadcast group | 24 /// be canceled. **Note that single-subscription streams in a broadcast group |
25 /// may drop events if a listener is added and later removed.** Broadcast | 25 /// may drop events if a listener is added and later removed.** Broadcast |
26 /// streams in the group will be canceled once [stream] has no listeners, and | 26 /// streams in the group will be canceled once [stream] has no listeners, and |
27 /// will be listened to again once [stream] has listeners. | 27 /// will be listened to again once [stream] has listeners. |
28 /// | 28 /// |
29 /// [stream] won't close until [close] is called on the group *and* every stream | 29 /// [stream] won't close until [close] is called on the group *and* every stream |
30 /// in the group closes. | 30 /// in the group closes. |
31 class StreamGroup<T> implements Sink<Stream<T>> { | 31 class StreamGroup<T> implements Sink<Stream<T>> { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 /// The name of the state. | 251 /// The name of the state. |
252 /// | 252 /// |
253 /// Used for debugging. | 253 /// Used for debugging. |
254 final String name; | 254 final String name; |
255 | 255 |
256 const _StreamGroupState(this.name); | 256 const _StreamGroupState(this.name); |
257 | 257 |
258 String toString() => name; | 258 String toString() => name; |
259 } | 259 } |
OLD | NEW |