| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 StreamController({void onPauseStateChange(), | 56 StreamController({void onPauseStateChange(), |
| 57 void onSubscriptionStateChange()}) | 57 void onSubscriptionStateChange()}) |
| 58 : stream = new _SingleControllerStream<T>(onSubscriptionStateChange, | 58 : stream = new _SingleControllerStream<T>(onSubscriptionStateChange, |
| 59 onPauseStateChange); | 59 onPauseStateChange); |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Returns a view of this object that only exposes the [StreamSink] interface. | 62 * Returns a view of this object that only exposes the [StreamSink] interface. |
| 63 */ | 63 */ |
| 64 StreamSink<T> get sink => new StreamSinkView<T>(this); | 64 StreamSink<T> get sink => new StreamSinkView<T>(this); |
| 65 | 65 |
| 66 /** |
| 67 * Whether the stream is closed for adding more events. |
| 68 * |
| 69 * If true, the "done" event might not have fired yet, but it has been |
| 70 * scheduled, and it is too late to add more events. |
| 71 */ |
| 72 bool get isClosed => stream._isClosed; |
| 73 |
| 66 /** Whether one or more active subscribers have requested a pause. */ | 74 /** Whether one or more active subscribers have requested a pause. */ |
| 67 bool get isPaused => stream._isPaused; | 75 bool get isPaused => stream._isPaused; |
| 68 | 76 |
| 69 /** Whether there are currently any subscribers on this [Stream]. */ | 77 /** Whether there are currently any subscribers on this [Stream]. */ |
| 70 bool get hasSubscribers => stream._hasSubscribers; | 78 bool get hasSubscribers => stream._hasSubscribers; |
| 71 | 79 |
| 72 /** | 80 /** |
| 73 * Send or queue a data event. | 81 * Send or queue a data event. |
| 74 */ | 82 */ |
| 75 void add(T value) => stream._add(value); | 83 void add(T value) => stream._add(value); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 _SingleControllerStream(this._subscriptionHandler, this._pauseHandler); | 137 _SingleControllerStream(this._subscriptionHandler, this._pauseHandler); |
| 130 | 138 |
| 131 void _onSubscriptionStateChange() { | 139 void _onSubscriptionStateChange() { |
| 132 if (_subscriptionHandler != null) _subscriptionHandler(); | 140 if (_subscriptionHandler != null) _subscriptionHandler(); |
| 133 } | 141 } |
| 134 | 142 |
| 135 void _onPauseStateChange() { | 143 void _onPauseStateChange() { |
| 136 if (_pauseHandler != null) _pauseHandler(); | 144 if (_pauseHandler != null) _pauseHandler(); |
| 137 } | 145 } |
| 138 } | 146 } |
| OLD | NEW |