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

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

Issue 11740027: Rename unsubscribe to cancel. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Address comments. 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
« no previous file with comments | « sdk/lib/async/merge_stream.dart ('k') | sdk/lib/async/stream_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/stream.dart
diff --git a/sdk/lib/async/stream.dart b/sdk/lib/async/stream.dart
index 32d0fcf1bc7896ce5b44e6d62a452a126186726b..ffa10233ca043a6f3d0658816d3b15c251e44d4c 100644
--- a/sdk/lib/async/stream.dart
+++ b/sdk/lib/async/stream.dart
@@ -134,7 +134,7 @@ abstract class Stream<T> {
try {
value = combine(value, element);
} catch (e, s) {
- subscription.unsubscribe();
+ subscription.cancel();
completer.completeError(e, s);
}
},
@@ -174,10 +174,10 @@ abstract class Stream<T> {
Future<bool> contains(T match) {
_FutureImpl<bool> future = new _FutureImpl<bool>();
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(T element) {
if (element == match) {
- subscription.unsubscribe();
+ subscription.cancel();
future._setValue(true);
}
},
@@ -198,10 +198,10 @@ abstract class Stream<T> {
Future<bool> every(bool test(T element)) {
_FutureImpl<bool> future = new _FutureImpl<bool>();
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(T element) {
if (!test(element)) {
- subscription.unsubscribe();
+ subscription.cancel();
future._setValue(false);
}
},
@@ -222,10 +222,10 @@ abstract class Stream<T> {
Future<bool> any(bool test(T element)) {
_FutureImpl<bool> future = new _FutureImpl<bool>();
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(T element) {
if (test(element)) {
- subscription.unsubscribe();
+ subscription.cancel();
future._setValue(true);
}
},
@@ -242,7 +242,7 @@ abstract class Stream<T> {
Future<int> get length {
_FutureImpl<int> future = new _FutureImpl<int>();
int count = 0;
- listen(
+ this.listen(
(_) { count++; },
onError: future._setError,
onDone: () {
@@ -267,7 +267,7 @@ abstract class Stream<T> {
_FutureImpl<T> future = new _FutureImpl<T>();
StreamSubscription subscription;
T min = null;
- subscription = listen(
+ subscription = this.listen(
(T value) {
min = value;
subscription.onData((T value) {
@@ -298,7 +298,7 @@ abstract class Stream<T> {
_FutureImpl<T> future = new _FutureImpl<T>();
StreamSubscription subscription;
T max = null;
- subscription = listen(
+ subscription = this.listen(
(T value) {
max = value;
subscription.onData((T value) {
@@ -318,9 +318,9 @@ abstract class Stream<T> {
Future<bool> get isEmpty {
_FutureImpl<bool> future = new _FutureImpl<bool>();
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(_) {
- subscription.unsubscribe();
+ subscription.cancel();
future._setValue(false);
},
onError: future._setError,
@@ -335,7 +335,7 @@ abstract class Stream<T> {
Future<List<T>> toList() {
List<T> result = <T>[];
_FutureImpl<List<T>> future = new _FutureImpl<List<T>>();
- listen(
+ this.listen(
(T data) {
result.add(data);
},
@@ -351,7 +351,7 @@ abstract class Stream<T> {
Future<Set<T>> toSet() {
Set<T> result = new Set<T>();
_FutureImpl<Set<T>> future = new _FutureImpl<Set<T>>();
- listen(
+ this.listen(
(T data) {
result.add(data);
},
@@ -429,10 +429,10 @@ abstract class Stream<T> {
Future<T> get first {
_FutureImpl<T> future = new _FutureImpl();
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(T value) {
future._setValue(value);
- subscription.unsubscribe();
+ subscription.cancel();
return;
},
onError: future._setError,
@@ -453,7 +453,7 @@ abstract class Stream<T> {
T result = null;
bool foundResult = false;
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(T value) {
foundResult = true;
result = value;
@@ -480,13 +480,13 @@ abstract class Stream<T> {
T result = null;
bool foundResult = false;
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(T value) {
if (foundResult) {
// This is the second element we get.
Error error = new StateError("More than one element");
future._setError(new AsyncError(error));
- subscription.unsubscribe();
+ subscription.cancel();
return;
}
foundResult = true;
@@ -521,19 +521,19 @@ abstract class Stream<T> {
Future<T> firstMatching(bool test(T value), {T defaultValue()}) {
_FutureImpl<T> future = new _FutureImpl<T>();
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(T value) {
bool matches;
try {
matches = (true == test(value));
} catch (e, s) {
future._setError(new AsyncError(e, s));
- subscription.unsubscribe();
+ subscription.cancel();
return;
}
if (matches) {
future._setValue(value);
- subscription.unsubscribe();
+ subscription.cancel();
}
},
onError: future._setError,
@@ -568,14 +568,14 @@ abstract class Stream<T> {
T result = null;
bool foundResult = false;
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(T value) {
bool matches;
try {
matches = (true == test(value));
} catch (e, s) {
future._setError(new AsyncError(e, s));
- subscription.unsubscribe();
+ subscription.cancel();
return;
}
if (matches) {
@@ -618,21 +618,21 @@ abstract class Stream<T> {
T result = null;
bool foundResult = false;
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(T value) {
bool matches;
try {
matches = (true == test(value));
} catch (e, s) {
future._setError(new AsyncError(e, s));
- subscription.unsubscribe();
+ subscription.cancel();
return;
}
if (matches) {
if (foundResult) {
future._setError(new AsyncError(
new StateError('Multiple matches for "single"')));
- subscription.unsubscribe();
+ subscription.cancel();
return;
}
foundResult = true;
@@ -663,11 +663,11 @@ abstract class Stream<T> {
Future<T> elementAt(int index) {
_FutureImpl<T> future = new _FutureImpl();
StreamSubscription subscription;
- subscription = listen(
+ subscription = this.listen(
(T value) {
if (index == 0) {
future._setValue(value);
- subscription.unsubscribe();
+ subscription.cancel();
return;
}
index -= 1;
@@ -697,7 +697,7 @@ abstract class StreamSubscription<T> {
* If an event is currently firing, this unsubscription will only
* take effect after all subscribers have received the current event.
*/
- void unsubscribe();
+ void cancel();
/** Set or override the data event handler of this subscription. */
void onData(void handleData(T data));
« no previous file with comments | « sdk/lib/async/merge_stream.dart ('k') | sdk/lib/async/stream_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698