| 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 StreamSubscription subscribe({void onData(T data), | 59 StreamSubscription listen(void onData(T data), |
| 60 void onError(AsyncError error), | 60 { void onError(AsyncError error), |
| 61 void onDone(), | 61 void onDone(), |
| 62 bool unsubscribeOnError}) { | 62 bool unsubscribeOnError}) { |
| 63 return _stream.subscribe(onData: onData, | 63 return _stream.listen(onData, |
| 64 onError: onError, | 64 onError: onError, |
| 65 onDone: onDone, | 65 onDone: onDone, |
| 66 unsubscribeOnError: unsubscribeOnError); | 66 unsubscribeOnError: unsubscribeOnError); |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Returns a view of this object that only exposes the [StreamSink] interface. | 70 * Returns a view of this object that only exposes the [StreamSink] interface. |
| 71 */ | 71 */ |
| 72 StreamSink<T> get sink => new StreamSinkView<T>(this); | 72 StreamSink<T> get sink => new StreamSinkView<T>(this); |
| 73 | 73 |
| 74 /** Whether one or more active subscribers have requested a pause. */ | 74 /** Whether one or more active subscribers have requested a pause. */ |
| 75 bool get isPaused => _stream._isPaused; | 75 bool get isPaused => _stream._isPaused; |
| 76 | 76 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 _SingleControllerStream(this._subscriptionHandler, this._pauseHandler); | 147 _SingleControllerStream(this._subscriptionHandler, this._pauseHandler); |
| 148 | 148 |
| 149 void _onSubscriptionStateChange() { | 149 void _onSubscriptionStateChange() { |
| 150 _subscriptionHandler(); | 150 _subscriptionHandler(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void _onPauseStateChange() { | 153 void _onPauseStateChange() { |
| 154 _pauseHandler(); | 154 _pauseHandler(); |
| 155 } | 155 } |
| 156 } | 156 } |
| OLD | NEW |