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

Unified Diff: packages/quiver/lib/src/async/metronome.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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 | « packages/quiver/lib/src/async/iteration.dart ('k') | packages/quiver/lib/src/async/stream_buffer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/quiver/lib/src/async/metronome.dart
diff --git a/packages/quiver/lib/src/async/metronome.dart b/packages/quiver/lib/src/async/metronome.dart
index 41dc6972f0ed98188e8adb8c85eeb804d69d4715..b7a10dae1b9ece32f6903c48a54e19acca9afcce 100644
--- a/packages/quiver/lib/src/async/metronome.dart
+++ b/packages/quiver/lib/src/async/metronome.dart
@@ -14,39 +14,37 @@
part of quiver.async;
-/**
- * A stream of [DateTime] events at [interval]s centered on [anchor].
- *
- * This stream accounts for drift but only guarantees that events are
- * delivered on or after the interval. If the system is busy for longer than
- * two [interval]s, only one will be delivered.
- *
- * [anchor] defaults to [clock.now], which means the stream represents a
- * self-correcting periodic timer. If anchor is the epoch, then the stream is
- * synchronized to wall-clock time. It can be anchored anywhere in time, but
- * this does not delay the first delivery.
- *
- * Examples:
- *
- * new Metronome.epoch(aMinute).listen((d) => print(d));
- *
- * Could print the following stream of events, anchored by epoch,
- * till the stream is canceled:
- * 2014-05-04 14:06:00.001
- * 2014-05-04 14:07:00.000
- * 2014-05-04 14:08:00.003
- * ...
- *
- * Example anchored in the future (now = 2014-05-05 20:06:00.123)
- * new IsochronousStream.periodic(aMillisecond * 100,
- * anchorMs: DateTime.parse("2014-05-05 21:07:00"))
- * .listen((d) => print(d));
- *
- * 2014-05-04 20:06:00.223
- * 2014-05-04 20:06:00.324
- * 2014-05-04 20:06:00.423
- * ...
- */
+/// A stream of [DateTime] events at [interval]s centered on [anchor].
+///
+/// This stream accounts for drift but only guarantees that events are
+/// delivered on or after the interval. If the system is busy for longer than
+/// two [interval]s, only one will be delivered.
+///
+/// [anchor] defaults to [clock.now], which means the stream represents a
+/// self-correcting periodic timer. If anchor is the epoch, then the stream is
+/// synchronized to wall-clock time. It can be anchored anywhere in time, but
+/// this does not delay the first delivery.
+///
+/// Examples:
+///
+/// new Metronome.epoch(aMinute).listen((d) => print(d));
+///
+/// Could print the following stream of events, anchored by epoch, till the
+/// stream is canceled:
+/// 2014-05-04 14:06:00.001
+/// 2014-05-04 14:07:00.000
+/// 2014-05-04 14:08:00.003
+/// ...
+///
+/// Example anchored in the future (now = 2014-05-05 20:06:00.123)
+/// new IsochronousStream.periodic(aMillisecond * 100,
+/// anchorMs: DateTime.parse("2014-05-05 21:07:00"))
+/// .listen(print);
+///
+/// 2014-05-04 20:06:00.223
+/// 2014-05-04 20:06:00.324
+/// 2014-05-04 20:06:00.423
+/// ...
class Metronome extends Stream<DateTime> {
static final DateTime _EPOCH = new DateTime.fromMillisecondsSinceEpoch(0);
@@ -55,7 +53,7 @@ class Metronome extends Stream<DateTime> {
final DateTime anchor;
Timer _timer;
- StreamController _controller;
+ StreamController<DateTime> _controller;
final int _intervalMs;
final int _anchorMs;
@@ -73,15 +71,16 @@ class Metronome extends Stream<DateTime> {
this.anchor = anchor,
this.interval = interval,
this._intervalMs = interval.inMilliseconds,
- this._anchorMs = (anchor == null
- ? clock.now()
- : anchor).millisecondsSinceEpoch {
+ this._anchorMs =
+ (anchor == null ? clock.now() : anchor).millisecondsSinceEpoch {
_controller = new StreamController<DateTime>.broadcast(
- sync: true, onCancel: () {
- _timer.cancel();
- }, onListen: () {
- _startTimer(clock.now());
- });
+ sync: true,
+ onCancel: () {
+ _timer.cancel();
+ },
+ onListen: () {
+ _startTimer(clock.now());
+ });
}
StreamSubscription<DateTime> listen(void onData(DateTime event),
« no previous file with comments | « packages/quiver/lib/src/async/iteration.dart ('k') | packages/quiver/lib/src/async/stream_buffer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698