Last active
August 29, 2015 14:23
-
-
Save nporteschaikin/1a08b57dda62aef32947 to your computer and use it in GitHub Desktop.
A tiny event emitter
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
!function(){var a=function(){};a.prototype={on:function(a,b){return this.events||(this.events={}),this.events[a]||(this.events[a]=[]),this.events[a].push(b),this},off:function(a,b){return(this.events||{})[a]&&(b?this.events[a].splice(this.events[a].indexOf(b),1):this.events[a]=[]),this},emit:function(a){if((this.events||{})[a])for(var b=0;b<this.events[a].length;b++)(this.events[a][b]||function(){}).apply(this,Array.prototype.slice.call(arguments,1));return this}},"function"==typeof define&&define.amd?define(a):"object"==typeof exports?module.exports=a:window.Emitter=a}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment