Skip to content

Instantly share code, notes, and snippets.

@doxas
Created November 30, 2018 01:15
Show Gist options
  • Save doxas/59c97e45f83b2a53d4c86b0be65d19d3 to your computer and use it in GitHub Desktop.
Save doxas/59c97e45f83b2a53d4c86b0be65d19d3 to your computer and use it in GitHub Desktop.
class Emitter {
static get EVENTS(){return [
'renderingComplete',
'focusComplete'
];}
constructor(){
this.listeners = {};
}
emit(eventName, arg){
if(this.listeners.hasOwnProperty(eventName) === true){
this.listeners[eventName](arg);
}
}
on(eventName, listener){
this.listeners[eventName] = listener;
}
off(eventName){
this.listeners[eventName] = null;
}
animation(){
let time = Date.now();
this.emit('animationBeforeStart', time);
animationStart = time;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment