Created
October 27, 2016 15:16
-
-
Save NetanelBasal/8263d83d6a20e4c64dbf2bbd03f814b3 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
let input = document.querySelector('input[type="text"]'); | |
let button = document.querySelector('button'); | |
let h1 = document.querySelector('h1'); | |
button.addEventListener('click', () => { | |
emitter.emit('event:name-changed', {name: input.value}); | |
}); | |
let emitter = new EventEmitter(); | |
emitter.subscribe('event:name-changed', data => { | |
h1.innerHTML = `Your name is: ${data.name}`; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment