blob: 01048ea844913e43e04b6cb342eff985d46d9597 [file] [log] [blame]
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// 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.
part of html;
// TODO(antonm): support not DOM isolates too.
class _Timer implements Timer {
final canceller;
_Timer(this.canceller);
void cancel() { canceller(); }
}
get _timerFactoryClosure => (int milliSeconds, void callback(Timer timer), bool repeating) {
var maker;
var canceller;
if (repeating) {
maker = window._setInterval;
canceller = window._clearInterval;
} else {
maker = window._setTimeout;
canceller = window._clearTimeout;
}
Timer timer;
final int id = maker(() { callback(timer); }, milliSeconds);
timer = new _Timer(() { canceller(id); });
return timer;
};