Created
May 5, 2017 18:40
-
-
Save coltpini/5d4a67e88cad10b8e2577ab8133b0d91 to your computer and use it in GitHub Desktop.
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
const someReallyAwesomeFunction = () => { | |
//some process that you want to know when it is finished in an async way. | |
//After we are finished with the process, then we can push an event | |
// with custom events we can attach what ever data we need to pass. | |
let myEvent = new CustomEvent('customEventName', { | |
detail: { | |
obj: 'that you can pass with the event!', | |
pass: 'what ever you want' | |
}, | |
// stick your options here | |
bubbles: true, | |
cancelable: false | |
}; | |
this.dispatchEvent(myEvent); | |
}; | |
// Events follow the capture and bubble flow, so you can't know if it isn't attached to something in that flow. | |
someobj.addEventListener('customeEventName', (e) => console.log(e.detail) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
line:21
custom*e*EventName