| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Core Stream types | 8 // Core Stream types |
| 9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 Duration elapsed = watch.elapsed; | 125 Duration elapsed = watch.elapsed; |
| 126 watch.start(); | 126 watch.start(); |
| 127 timer = new Timer(period - elapsed, () { | 127 timer = new Timer(period - elapsed, () { |
| 128 timer = null; | 128 timer = null; |
| 129 startPeriodicTimer(); | 129 startPeriodicTimer(); |
| 130 sendEvent(); | 130 sendEvent(); |
| 131 }); | 131 }); |
| 132 } | 132 } |
| 133 }, | 133 }, |
| 134 onSubscriptionStateChange: () { | 134 onSubscriptionStateChange: () { |
| 135 if (controller.hasSubscribers) { | 135 if (controller.hasListener) { |
| 136 watch.start(); | 136 watch.start(); |
| 137 startPeriodicTimer(); | 137 startPeriodicTimer(); |
| 138 } else { | 138 } else { |
| 139 if (timer != null) timer.cancel(); | 139 if (timer != null) timer.cancel(); |
| 140 timer = null; | 140 timer = null; |
| 141 } | 141 } |
| 142 }); | 142 }); |
| 143 return controller.stream; | 143 return controller.stream; |
| 144 } | 144 } |
| 145 | 145 |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 StreamSubscription subscription; | 977 StreamSubscription subscription; |
| 978 controller = new StreamController<T>( | 978 controller = new StreamController<T>( |
| 979 onPauseStateChange: () { | 979 onPauseStateChange: () { |
| 980 if (controller.isPaused) { | 980 if (controller.isPaused) { |
| 981 subscription.pause(); | 981 subscription.pause(); |
| 982 } else { | 982 } else { |
| 983 subscription.resume(); | 983 subscription.resume(); |
| 984 } | 984 } |
| 985 }, | 985 }, |
| 986 onSubscriptionStateChange: () { | 986 onSubscriptionStateChange: () { |
| 987 if (controller.hasSubscribers) { | 987 if (controller.hasListener) { |
| 988 subscription = transformingStream.listen( | 988 subscription = transformingStream.listen( |
| 989 controller.add, | 989 controller.add, |
| 990 onError: controller.addError, | 990 onError: controller.addError, |
| 991 onDone: controller.close); | 991 onDone: controller.close); |
| 992 } else { | 992 } else { |
| 993 subscription.cancel(); | 993 subscription.cancel(); |
| 994 } | 994 } |
| 995 }); | 995 }); |
| 996 return controller.stream; | 996 return controller.stream; |
| 997 } | 997 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 class _EventOutputSinkWrapper<T> extends EventSink<T> { | 1155 class _EventOutputSinkWrapper<T> extends EventSink<T> { |
| 1156 _EventOutputSink _sink; | 1156 _EventOutputSink _sink; |
| 1157 _EventOutputSinkWrapper(this._sink); | 1157 _EventOutputSinkWrapper(this._sink); |
| 1158 | 1158 |
| 1159 void add(T data) { _sink._sendData(data); } | 1159 void add(T data) { _sink._sendData(data); } |
| 1160 void addError(AsyncError error) { _sink._sendError(error); } | 1160 void addError(AsyncError error) { _sink._sendError(error); } |
| 1161 void close() { _sink._sendDone(); } | 1161 void close() { _sink._sendDone(); } |
| 1162 } | 1162 } |
| OLD | NEW |