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

Side by Side Diff: sdk/lib/async/timer.dart

Issue 12342014: Remove deprecated ms arguments for Timer and Future. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 part of dart.async; 5 part of dart.async;
6 6
7 abstract class Timer { 7 abstract class Timer {
8 /** 8 /**
9 * Creates a new timer. 9 * Creates a new timer.
10 * 10 *
11 * The [callback] callback is invoked after the given [duration] 11 * The [callback] callback is invoked after the given [duration].
12 * (a [Duration]) has passed. A negative duration is treated similar to 12 * A negative duration is treated similar to a duration of 0.
13 * a duration of 0.
14 * 13 *
15 * If the [duration] is statically known to be 0, consider using [run]. 14 * If the [duration] is statically known to be 0, consider using [run].
16 * 15 *
17 * Frequently the [duration] is either a constant or computed as in the 16 * Frequently the [duration] is either a constant or computed as in the
18 * following example (taking advantage of the multiplication operator of 17 * following example (taking advantage of the multiplication operator of
19 * the Duration class): 18 * the Duration class):
20 * 19 *
21 * const TIMEOUT = const Duration(seconds: 3); 20 * const TIMEOUT = const Duration(seconds: 3);
22 * const ms = const Duration(milliseconds: 1); 21 * const ms = const Duration(milliseconds: 1);
23 * 22 *
24 * startTimeout([int milliseconds]) { 23 * startTimeout([int milliseconds]) {
25 * var duration = milliseconds == null ? TIMEOUT : ms * milliseconds; 24 * var duration = milliseconds == null ? TIMEOUT : ms * milliseconds;
26 * return new Timer(duration, handleTimeout); 25 * return new Timer(duration, handleTimeout);
27 * } 26 * }
28 *
29 * *Deprecation warning*: this constructor used to take an [int] (the time
30 * in milliseconds) and a callback with one argument (the timer). This has
31 * changed to a [Duration] and a callback without arguments.
32 */ 27 */
33 // TODO(floitsch): add types. 28 external factory Timer(Duration duration, void callback());
34 external factory Timer(var duration, Function callback);
35 29
36 /** 30 /**
37 * Creates a new repeating timer. 31 * Creates a new repeating timer.
38 * 32 *
39 * The [callback] is invoked repeatedly with [duration] intervals until 33 * The [callback] is invoked repeatedly with [duration] intervals until
40 * canceled. A negative duration is treated similar to a duration of 0. 34 * canceled. A negative duration is treated similar to a duration of 0.
41 *
42 * *Deprecation warning*: this constructor used to take an [int] (the time
43 * in milliseconds). This has changed to a [Duration].
44 */ 35 */
45 external factory Timer.repeating(var duration, 36 external factory Timer.repeating(Duration duration,
46 void callback(Timer timer)); 37 void callback(Timer timer));
47 38
48 /** 39 /**
49 * Runs the given [callback] asynchronously as soon as possible. 40 * Runs the given [callback] asynchronously as soon as possible.
50 * 41 *
51 * Returns a [Timer] that can be cancelled if the callback is not necessary 42 * Returns a [Timer] that can be cancelled if the callback is not necessary
52 * anymore. 43 * anymore.
53 */ 44 */
54 static Timer run(void callback()) { 45 static Timer run(void callback()) {
55 return new Timer(const Duration(), callback); 46 return new Timer(const Duration(milliseconds: 0), callback);
56 } 47 }
57 48
58 /** 49 /**
59 * Cancels the timer. 50 * Cancels the timer.
60 */ 51 */
61 void cancel(); 52 void cancel();
62 } 53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698