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 // ------------------------------------------------------------------- | 7 // ------------------------------------------------------------------- |
8 // Controller for creating and adding events to a stream. | 8 // Controller for creating and adding events to a stream. |
9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 * Whether to invoke a callback depends only on the state before and after | 39 * Whether to invoke a callback depends only on the state before and after |
40 * a stream action, for example firing an event. If the state changes multiple | 40 * a stream action, for example firing an event. If the state changes multiple |
41 * times during the action, and then ends up in the same state as before, no | 41 * times during the action, and then ends up in the same state as before, no |
42 * callback is performed. | 42 * callback is performed. |
43 * | 43 * |
44 * If listeners are added after the stream has completed (sent a "done" event), | 44 * If listeners are added after the stream has completed (sent a "done" event), |
45 * the listeners will be sent a "done" event eventually, but they won't affect | 45 * the listeners will be sent a "done" event eventually, but they won't affect |
46 * the stream at all, and won't trigger callbacks. From the controller's point | 46 * the stream at all, and won't trigger callbacks. From the controller's point |
47 * of view, the stream is completely inert when has completed. | 47 * of view, the stream is completely inert when has completed. |
48 */ | 48 */ |
49 class StreamController<T> extends StreamSink<T> { | 49 class StreamController<T> extends EventSink<T> { |
50 // TODO(8997): Implement EventSink instead. | |
51 final _StreamImpl<T> stream; | 50 final _StreamImpl<T> stream; |
52 | 51 |
53 /** | 52 /** |
54 * A controller with a broadcast [stream].. | 53 * A controller with a broadcast [stream].. |
55 * | 54 * |
56 * The [onPauseStateChange] function is called when the stream becomes | 55 * The [onPauseStateChange] function is called when the stream becomes |
57 * paused or resumes after being paused. The current pause state can | 56 * paused or resumes after being paused. The current pause state can |
58 * be read from [isPaused]. Ignored if [:null:]. | 57 * be read from [isPaused]. Ignored if [:null:]. |
59 * | 58 * |
60 * The [onSubscriptionStateChange] function is called when the stream | 59 * The [onSubscriptionStateChange] function is called when the stream |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 void _onPauseStateChange() { | 187 void _onPauseStateChange() { |
189 if (_pauseHandler != null) { | 188 if (_pauseHandler != null) { |
190 try { | 189 try { |
191 _pauseHandler(); | 190 _pauseHandler(); |
192 } catch (e, s) { | 191 } catch (e, s) { |
193 new AsyncError(e, s).throwDelayed(); | 192 new AsyncError(e, s).throwDelayed(); |
194 } | 193 } |
195 } | 194 } |
196 } | 195 } |
197 } | 196 } |
OLD | NEW |