Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Unified Diff: sdk/lib/async/stream_impl.dart

Issue 11740027: Rename unsubscribe to cancel. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Fix error message. Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/async/stream_impl.dart
diff --git a/sdk/lib/async/stream_impl.dart b/sdk/lib/async/stream_impl.dart
index d9d36b8550a654628d90d5ab4fdafc596856dd6e..ea451081eff0d4a1bd88468d96a62ff137d36bda 100644
--- a/sdk/lib/async/stream_impl.dart
+++ b/sdk/lib/async/stream_impl.dart
@@ -62,10 +62,10 @@ abstract class _StreamImpl<T> extends Stream<T> {
// ------------------------------------------------------------------
// Stream interface.
- StreamSubscription subscribe({void onData(T data),
- void onError(AsyncError error),
- void onDone(),
- bool unsubscribeOnError}) {
+ StreamSubscription listen(void onData(T data),
+ { void onError(AsyncError error),
+ void onDone(),
+ bool unsubscribeOnError}) {
if (_isComplete) {
return new _DoneSubscription(onDone);
}
@@ -266,12 +266,12 @@ abstract class _StreamImpl<T> extends Stream<T> {
/**
* Handle an unsubscription requested from a [_StreamSubscriptionImpl].
*
- * This method is called from [_StreamSubscriptionImpl.unsubscribe].
+ * This method is called from [_StreamSubscriptionImpl.cancel].
*
* If an event is currently firing, the subscription is delayed
* until after the event has been sent to all subscribers.
*/
- void _unsubscribe(_StreamSubscriptionImpl subscriber);
+ void _cancel(_StreamSubscriptionImpl subscriber);
/**
* Iterate over all current subscribers and perform an action on each.
@@ -360,7 +360,7 @@ abstract class _StreamImpl<T> extends Stream<T> {
_setComplete();
if (!_hasSubscribers) return;
_forEachSubscriber((subscriber) {
- _unsubscribe(subscriber);
+ _cancel(subscriber);
try {
subscriber._sendDone();
} catch (e, s) {
@@ -440,12 +440,12 @@ class _SingleStreamImpl<T> extends _StreamImpl<T> {
/**
* Handle an unsubscription requested from a [_StreamSubscriptionImpl].
Lasse Reichstein Nielsen 2013/01/04 08:17:55 a cancel request.
floitsch 2013/01/04 15:51:36 Done.
*
- * This method is called from [_StreamSubscriptionImpl.unsubscribe].
+ * This method is called from [_StreamSubscriptionImpl.cancel].
*
* If an event is currently firing, the subscription is delayed
Lasse Reichstein Nielsen 2013/01/04 08:17:55 subscription (sic) -> cancel. Perhaps also -> "...
floitsch 2013/01/04 15:51:36 Done.
* until after the event has been sent to all subscribers.
*/
- void _unsubscribe(_StreamSubscriptionImpl subscriber) {
+ void _cancel(_StreamSubscriptionImpl subscriber) {
assert(identical(subscriber._source, this));
// We allow unsubscribing the currently firing subscription during
// the event firing, because it is indistinguishable from delaying it since
@@ -582,12 +582,12 @@ class _MultiStreamImpl<T> extends _StreamImpl<T>
/**
* Handle an unsubscription requested from a [_StreamListener].
*
- * This method is called from [_StreamListener.unsubscribe].
+ * This method is called from [_StreamListener.cancel].
*
* If an event is currently firing, the unsubscription is delayed
* until after the event has been sent to all subscribers.
*/
- void _unsubscribe(_StreamListener listener) {
+ void _cancel(_StreamListener listener) {
assert(identical(listener._source, this));
if (_InternalLink.isUnlinked(listener)) {
// You may unsubscribe more than once, only the first one counts.
@@ -673,15 +673,15 @@ class _StreamSubscriptionImpl<T> extends _StreamListener<T>
void _sendError(AsyncError error) {
_onError(error);
- if (_unsubscribeOnError) _source._unsubscribe(this);
+ if (_unsubscribeOnError) _source._cancel(this);
}
void _sendDone() {
_onDone();
}
- void unsubscribe() {
- _source._unsubscribe(this);
+ void cancel() {
+ _source._cancel(this);
}
void pause([Signal resumeSignal]) {
@@ -985,7 +985,7 @@ class _DoneSubscription<T> implements StreamSubscription<T> {
void pause([Signal signal]) {
if (_isComplete) {
- throw new StateError("Subscription has been unsubscribed.");
+ throw new StateError("Subscription has been canceled.");
}
if (_timer != null) _timer.cancel();
_pauseCount++;
@@ -993,7 +993,7 @@ class _DoneSubscription<T> implements StreamSubscription<T> {
void resume() {
if (_isComplete) {
- throw new StateError("Subscription has been unsubscribed.");
+ throw new StateError("Subscription has been canceled.");
}
if (_pauseCount == 0) return;
_pauseCount--;
@@ -1004,9 +1004,9 @@ class _DoneSubscription<T> implements StreamSubscription<T> {
bool get isPaused => _pauseCount > 0;
- void unsubscribe() {
+ void cancel() {
if (_isComplete) {
- throw new StateError("Subscription has been unsubscribed.");
+ throw new StateError("Subscription has been canceled.");
}
if (_timer != null) {
_timer.cancel();

Powered by Google App Engine
This is Rietveld 408576698