Created
November 30, 2018 01:15
-
-
Save doxas/59c97e45f83b2a53d4c86b0be65d19d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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