OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 patch class Timer { |
| 6 /* patch */ factory Timer(int milliseconds, void callback(Timer timer)) { |
| 7 if (_TimerFactory._factory == null) { |
| 8 throw new UnsupportedError("Timer interface not supported."); |
| 9 } |
| 10 return _TimerFactory._factory(milliseconds, callback, false); |
| 11 } |
| 12 |
| 13 /** |
| 14 * Creates a new repeating timer. The [callback] is invoked every |
| 15 * [milliseconds] millisecond until cancelled. |
| 16 */ |
| 17 /* patch */ factory Timer.repeating(int milliseconds, |
| 18 void callback(Timer timer)) { |
| 19 if (_TimerFactory._factory == null) { |
| 20 throw new UnsupportedError("Timer interface not supported."); |
| 21 } |
| 22 return _TimerFactory._factory(milliseconds, callback, true); |
| 23 } |
| 24 } |
| 25 |
| 26 typedef Timer _TimerFactoryClosure(int milliseconds, |
| 27 void callback(Timer timer), |
| 28 bool repeating); |
| 29 |
| 30 class _TimerFactory { |
| 31 static _TimerFactoryClosure _factory; |
| 32 } |
| 33 |
| 34 // TODO(ahe): Warning: this is NOT called by Dartium. Instead, it sets |
| 35 // [_TimerFactory._factory] directly. |
| 36 void _setTimerFactoryClosure(_TimerFactoryClosure closure) { |
| 37 _TimerFactory._factory = closure; |
| 38 } |
OLD | NEW |