import EventEmitter from "events";

import App from "../app.js";

class SimpleStore extends EventEmitter {

  constructor(props) {
    super(props);
    this.props = props;
    this.dispatchToken = props.dispatcher.register(this.dispatch.bind(this));
  }

  update(data) {
    this.datum = data.sort((a, b) => {return b.t - a.t;})[0];
    this.emit(App.TELEMETRY_EVENT);
  }

  dispatch(payload) {
    if (payload.actionType === "new-data") {
      // this.props.dispatcher.waitFor([this.dispatchToken]);
      this.update(payload.data);
    }
  }

  get() {
    return this.datum;
  }
}

export {SimpleStore as default};

@@ -270,26 +270,29 @@
 ) %7B%0A    
-this.datum
+const newData
  = data.
@@ -331,16 +331,97 @@
 ;%7D)%5B0%5D;%0A
+    if (!this.datum %7C%7C newData.t %3E this.datum.t) %7B%0A      this.datum = newData;%0A  
     this
@@ -448,16 +448,22 @@
 EVENT);%0A
+    %7D%0A
   %7D%0A%0A  d

Fix jitter on delay display.