| 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 // Default implementation of a stream with a controller for adding | 8 // Default implementation of a stream with a controller for adding |
| 9 // events to the stream. | 9 // events to the stream. |
| 10 // ------------------------------------------------------------------- | 10 // ------------------------------------------------------------------- |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 /** | 49 /** |
| 50 * A controller with a [stream] that supports only one single subscriber. | 50 * A controller with a [stream] that supports only one single subscriber. |
| 51 * The controller will buffer all incoming events until the subscriber is | 51 * The controller will buffer all incoming events until the subscriber is |
| 52 * registered. | 52 * registered. |
| 53 */ | 53 */ |
| 54 StreamController.singleSubscription() { | 54 StreamController.singleSubscription() { |
| 55 _stream = new _SingleControllerStream<T>(onSubscriptionStateChange, | 55 _stream = new _SingleControllerStream<T>(onSubscriptionStateChange, |
| 56 onPauseStateChange); | 56 onPauseStateChange); |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool get isSingleSubscription => _stream.isSingleSubscription; |
| 60 |
| 59 StreamSubscription listen(void onData(T data), | 61 StreamSubscription listen(void onData(T data), |
| 60 { void onError(AsyncError error), | 62 { void onError(AsyncError error), |
| 61 void onDone(), | 63 void onDone(), |
| 62 bool unsubscribeOnError}) { | 64 bool unsubscribeOnError}) { |
| 63 return _stream.listen(onData, | 65 return _stream.listen(onData, |
| 64 onError: onError, | 66 onError: onError, |
| 65 onDone: onDone, | 67 onDone: onDone, |
| 66 unsubscribeOnError: unsubscribeOnError); | 68 unsubscribeOnError: unsubscribeOnError); |
| 67 } | 69 } |
| 68 | 70 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 _SingleControllerStream(this._subscriptionHandler, this._pauseHandler); | 165 _SingleControllerStream(this._subscriptionHandler, this._pauseHandler); |
| 164 | 166 |
| 165 void _onSubscriptionStateChange() { | 167 void _onSubscriptionStateChange() { |
| 166 _subscriptionHandler(); | 168 _subscriptionHandler(); |
| 167 } | 169 } |
| 168 | 170 |
| 169 void _onPauseStateChange() { | 171 void _onPauseStateChange() { |
| 170 _pauseHandler(); | 172 _pauseHandler(); |
| 171 } | 173 } |
| 172 } | 174 } |
| OLD | NEW |