Created
May 14, 2018 11:36
-
-
Save ivarconr/67647a190e64707a99d831ae41026b3c to your computer and use it in GitHub Desktop.
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
// Create and add EventListner | |
const func = ev => {console.log(ev.detail)}; | |
const listner = window.addEventListener('demo', func); | |
// Publish custom event | |
const event = new CustomEvent('demo', {detail: 'hello world'}); | |
window.dispatchEvent(event); | |
// Remove EventListner | |
window.removeEventListener('demo', func); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment