import Signal from "./Signal.js";

class Ticker extends Signal {
  constructor() {
    super();
    
    this._updateBinded = this.update.bind(this);

    this._previousTimestamp = window.performance.now();
    this.deltaTime = 0;
    this.timeScale = 1;

    this.update();
  }

  update(time) {
    requestAnimationFrame(this._updateBinded);

    const timestamp = window.performance.now();
    this.deltaTime = (timestamp - this._previousTimestamp) * .001;
    this.timeScale = this.deltaTime / .0166666667;
    this._previousTimestamp = timestamp;

    this.dispatch(time);
  }
}

export default new Ticker();

@@ -120,24 +120,25 @@
 nded = this.
+_
 update.bind(
@@ -154,34 +154,20 @@
    this.
-_previousTimestamp
+time
  = windo
@@ -177,32 +177,75 @@
 erformance.now()
+ * .001;%0A    this._previousTime = this.time
 ;%0A    this.delta
@@ -288,16 +288,17 @@
    this.
+_
 update()
@@ -310,19 +310,16 @@
 %0A%0A  
+_
 update(
-time
 ) %7B%0A
@@ -374,23 +374,17 @@
     
-const timestamp
+this.time
  = w
@@ -406,16 +406,24 @@
 ce.now()
+ * 0.001
 ;%0A    th
@@ -441,18 +441,17 @@
 e = 
-(timestamp
+this.time
  - t
@@ -471,21 +471,8 @@
 Time
-stamp) * .001
 ;%0A  
@@ -546,25 +546,20 @@
 Time
-stamp = timestamp
+ = this.time
 ;%0A%0A 
@@ -575,20 +575,16 @@
 ispatch(
-time
 );%0A  %7D%0A%7D

add time to Ticker