dh_ackergaul
vor 4 Tagen bb80cdf5a6157ca1f3a276e12e9faae9a4739cb7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e) {
        reject(e);
      }
    };
    var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};
class ClockController {
  constructor(host_, timeout_ = 1e3, callback_) {
    (this._host = host_).addController(this);
    this._timeout = timeout_;
    this._callback = callback_;
  }
  hostConnected() {
    this._timerID = +setInterval(() => __async(this, null, function* () {
      if (yield this._callback()) {
        this._host.requestUpdate();
      }
    }), this._timeout);
  }
  hostDisconnected() {
    clearInterval(this._timerID);
    this._timerID = void 0;
  }
}
 
export { ClockController };