Skip to content

Instantly share code, notes, and snippets.

@felipemarcos
Last active January 25, 2016 05:10
Show Gist options
  • Save felipemarcos/f343e8049f6aded01876 to your computer and use it in GitHub Desktop.
Save felipemarcos/f343e8049f6aded01876 to your computer and use it in GitHub Desktop.
Custom Events
Element.prototype.dispatch = function(eventName, data) {
var event = data ? new CustomEvent(eventName, data) : new Event(eventName);
this.dispatchEvent(event);
}
document.body.addEventListener('start', function() {
console.log('hi');
});
document.body.dispatch('start');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment