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

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

Issue 14196003: Change StreamController constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and rebase. Created 7 years, 8 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 | « runtime/bin/socket_patch.dart ('k') | sdk/lib/async/stream_controller.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 d1fe15b67e2edd1645fdbeed4e3772cbd1e5d27b..9f0f6a7ffb71f323955b13acb285445a4e536e61 100644
--- a/sdk/lib/async/stream.dart
+++ b/sdk/lib/async/stream.dart
@@ -115,30 +115,28 @@ abstract class Stream<T> {
}
controller = new StreamController<T>(
- onPauseStateChange: () {
- if (controller.isPaused) {
- timer.cancel();
- timer = null;
- watch.stop();
- } else {
- assert(timer == null);
- Duration elapsed = watch.elapsed;
- watch.start();
- timer = new Timer(period - elapsed, () {
- timer = null;
- startPeriodicTimer();
- sendEvent();
- });
- }
+ onListen: () {
+ watch.start();
+ startPeriodicTimer();
},
- onSubscriptionStateChange: () {
- if (controller.hasListener) {
- watch.start();
- startPeriodicTimer();
- } else {
- if (timer != null) timer.cancel();
+ onPause: () {
+ timer.cancel();
+ timer = null;
+ watch.stop();
+ },
+ onResume: () {
+ assert(timer == null);
+ Duration elapsed = watch.elapsed;
+ watch.start();
+ timer = new Timer(period - elapsed, () {
timer = null;
- }
+ startPeriodicTimer();
+ sendEvent();
+ });
+ },
+ onCancel: () {
+ if (timer != null) timer.cancel();
+ timer = null;
});
return controller.stream;
}
@@ -1014,23 +1012,15 @@ abstract class StreamEventTransformer<S, T> implements StreamTransformer<S, T> {
StreamController controller;
StreamSubscription subscription;
controller = new StreamController<T>(
- onPauseStateChange: () {
- if (controller.isPaused) {
- subscription.pause();
- } else {
- subscription.resume();
- }
+ onListen: () {
+ subscription = transformingStream.listen(
+ controller.add,
+ onError: controller.addError,
+ onDone: controller.close);
},
- onSubscriptionStateChange: () {
- if (controller.hasListener) {
- subscription = transformingStream.listen(
- controller.add,
- onError: controller.addError,
- onDone: controller.close);
- } else {
- subscription.cancel();
- }
- });
+ onPause: () => subscription.pause(),
+ onResume: () => subscription.resume(),
+ onCancel: () => subscription.cancel());
return controller.stream;
}
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | sdk/lib/async/stream_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698