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

Side by Side Diff: tests/lib/async/event_helper.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, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 library event_helper; 5 library event_helper;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 class Event { 9 class Event {
10 void replay(StreamSink sink); 10 void replay(StreamSink sink);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 class CaptureEvents extends Events { 135 class CaptureEvents extends Events {
136 StreamSubscription subscription; 136 StreamSubscription subscription;
137 SignalCompleter onDoneSignal; 137 SignalCompleter onDoneSignal;
138 bool unsubscribeOnError = false; 138 bool unsubscribeOnError = false;
139 139
140 CaptureEvents(Stream stream, 140 CaptureEvents(Stream stream,
141 { bool unsubscribeOnError: false }) 141 { bool unsubscribeOnError: false })
142 : onDoneSignal = new SignalCompleter() { 142 : onDoneSignal = new SignalCompleter() {
143 this.unsubscribeOnError = unsubscribeOnError; 143 this.unsubscribeOnError = unsubscribeOnError;
144 subscription = stream.subscribe(onData: add, 144 subscription = stream.listen(add,
145 onError: signalError, 145 onError: signalError,
146 onDone: close, 146 onDone: close,
147 unsubscribeOnError: unsubscribeOnError); 147 unsubscribeOnError: unsubscribeOnError);
148 } 148 }
149 149
150 void signalError(AsyncError error) { 150 void signalError(AsyncError error) {
151 super.signalError(error); 151 super.signalError(error);
152 if (unsubscribeOnError) onDoneSignal.complete(); 152 if (unsubscribeOnError) onDoneSignal.complete();
153 } 153 }
154 154
155 void close() { 155 void close() {
156 super.close(); 156 super.close();
157 if (onDoneSignal != null) onDoneSignal.complete(); 157 if (onDoneSignal != null) onDoneSignal.complete();
158 } 158 }
159 159
160 void pause([Signal resumeSignal]) { 160 void pause([Signal resumeSignal]) {
161 subscription.pause(resumeSignal); 161 subscription.pause(resumeSignal);
162 } 162 }
163 163
164 void resume() { 164 void resume() {
165 subscription.resume(); 165 subscription.resume();
166 } 166 }
167 167
168 bool get isPaused => subscription.isPaused; 168 bool get isPaused => subscription.isPaused;
169 169
170 void onDone(void action()) { 170 void onDone(void action()) {
171 onDoneSignal.signal.then(action); 171 onDoneSignal.signal.then(action);
172 } 172 }
173 } 173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698