Chromium Code Reviews| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 bool get hasSubscribers => _stream._hasSubscribers; | 78 bool get hasSubscribers => _stream._hasSubscribers; |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Send or queue a data event. | 81 * Send or queue a data event. |
| 82 */ | 82 */ |
| 83 void add(T value) => _stream._add(value); | 83 void add(T value) => _stream._add(value); |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * Send or enqueue an error event. | 86 * Send or enqueue an error event. |
| 87 * | 87 * |
| 88 * If the [error] is an [AsyncError], it is used directly as the | |
| 89 * error object reported to listeners, and the [stackTrace] is ignored. | |
|
floitsch
2013/01/10 16:38:10
I would mention the special case after the normal
Lasse Reichstein Nielsen
2013/01/11 07:02:05
Done.
| |
| 90 * | |
| 91 * Otherwise the [exception] and an optional [stackTrace] is combined and sent | |
| 92 * this stream's listeners. | |
| 93 * | |
| 88 * If a subscription has requested to be unsubscribed on errors, | 94 * If a subscription has requested to be unsubscribed on errors, |
| 89 * it will be unsubscribed after receiving this event. | 95 * it will be unsubscribed after receiving this event. |
| 90 */ | 96 */ |
| 91 void signalError(AsyncError error) { _stream._signalError(error); } | 97 void signalError(Object error, [Object stackTrace]) { |
| 98 AsyncError asyncError; | |
| 99 if (error is AsyncError) { | |
| 100 asyncError = error; | |
| 101 } else { | |
| 102 asyncError = new AsyncError(error, stackTrace); | |
| 103 } | |
| 104 _stream._signalError(asyncError); | |
| 105 } | |
| 92 | 106 |
| 93 /** | 107 /** |
| 94 * Send or enqueue a "done" message. | 108 * Send or enqueue a "done" message. |
| 95 * | 109 * |
| 96 * The "done" message should be sent at most once by a stream, and it | 110 * The "done" message should be sent at most once by a stream, and it |
| 97 * should be the last message sent. | 111 * should be the last message sent. |
| 98 */ | 112 */ |
| 99 void close() { _stream._close(); } | 113 void close() { _stream._close(); } |
| 100 | 114 |
| 101 /** | 115 /** |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 _SingleControllerStream(this._subscriptionHandler, this._pauseHandler); | 161 _SingleControllerStream(this._subscriptionHandler, this._pauseHandler); |
| 148 | 162 |
| 149 void _onSubscriptionStateChange() { | 163 void _onSubscriptionStateChange() { |
| 150 _subscriptionHandler(); | 164 _subscriptionHandler(); |
| 151 } | 165 } |
| 152 | 166 |
| 153 void _onPauseStateChange() { | 167 void _onPauseStateChange() { |
| 154 _pauseHandler(); | 168 _pauseHandler(); |
| 155 } | 169 } |
| 156 } | 170 } |
| OLD | NEW |