Skip to content

Instantly share code, notes, and snippets.

@higordiego
Last active June 10, 2020 22:54
Show Gist options
  • Save higordiego/15bd8ae40b9f120527d3f1607f485a00 to your computer and use it in GitHub Desktop.
Save higordiego/15bd8ae40b9f120527d3f1607f485a00 to your computer and use it in GitHub Desktop.
window.functSubscribeElement = function () {
var elem = document.getElementById('test')
elem.addEventListener('event', (event) => console.log(event.detail), false)
return elem
}
window.eventDispatch = function (elem) {
var event = new CustomEvent('event', {
detail: {
value: 'hello'
}
})
elem.dispatchEvent(event)
}
const element = functSubscribeElement()
eventDispatch(element)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment