Skip to content

Instantly share code, notes, and snippets.

@shrynx
Last active December 24, 2016 05:19
Show Gist options
  • Save shrynx/f10b60a13e68e528b6770d4138faadd3 to your computer and use it in GitHub Desktop.
Save shrynx/f10b60a13e68e528b6770d4138faadd3 to your computer and use it in GitHub Desktop.
const events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
emit: function (eventName, data) {
if (this.events[eventName]) {
this.events[eventName].map(function(fn) {
fn(data);
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment