| Index: runtime/lib/timer_patch.dart
|
| diff --git a/runtime/lib/timer_patch.dart b/runtime/lib/timer_patch.dart
|
| index 87026b10c22bbb57143eadc2ed9ea8771c5de7c9..2db2343720a1e6ad6e14c7f6b9ea351075bbd68d 100644
|
| --- a/runtime/lib/timer_patch.dart
|
| +++ b/runtime/lib/timer_patch.dart
|
| @@ -2,26 +2,27 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -patch Timer _createTimer(Duration duration, void callback()) {
|
| - if (_TimerFactory._factory == null) {
|
| - throw new UnsupportedError("Timer interface not supported.");
|
| +patch class Timer {
|
| + /* patch */ factory Timer(Duration duration, void callback()) {
|
| + if (_TimerFactory._factory == null) {
|
| + throw new UnsupportedError("Timer interface not supported.");
|
| + }
|
| + int milliseconds = duration.inMilliseconds;
|
| + if (milliseconds < 0) milliseconds = 0;
|
| + return _TimerFactory._factory(milliseconds, (_) { callback(); }, false);
|
| }
|
| - int milliseconds = duration.inMilliseconds;
|
| - if (milliseconds < 0) milliseconds = 0;
|
| - return _TimerFactory._factory(milliseconds, (_) { callback(); }, false);
|
| -}
|
|
|
| -patch Timer _createPeriodicTimer(Duration duration,
|
| - void callback(Timer timer)) {
|
| - if (_TimerFactory._factory == null) {
|
| - throw new UnsupportedError("Timer interface not supported.");
|
| + /* patch */ factory Timer.periodic(Duration duration,
|
| + void callback(Timer timer)) {
|
| + if (_TimerFactory._factory == null) {
|
| + throw new UnsupportedError("Timer interface not supported.");
|
| + }
|
| + int milliseconds = duration.inMilliseconds;
|
| + if (milliseconds < 0) milliseconds = 0;
|
| + return _TimerFactory._factory(milliseconds, callback, true);
|
| }
|
| - int milliseconds = duration.inMilliseconds;
|
| - if (milliseconds < 0) milliseconds = 0;
|
| - return _TimerFactory._factory(milliseconds, callback, true);
|
| }
|
|
|
| -
|
| typedef Timer _TimerFactoryClosure(int milliseconds,
|
| void callback(Timer timer),
|
| bool repeating);
|
|
|