Last active
July 24, 2018 23:00
-
-
Save shiv19/50ea515932d8cdee9e1eb04809e4fa8a to your computer and use it in GitHub Desktop.
Event emitter one liner
This file contains 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
M=(o={})=>({on:(e,f)=>(o[e]=o[e]||[]).push(f),trigger:(e,d)=>(o[e]||[]).map(x=>x(d))}); | |
m = M(); | |
m.on("foo", (c) => console.log(c)); //register | |
m.trigger("foo",4) //invoke |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment