Created
August 21, 2019 09:05
-
-
Save mattiaslundberg/674f32960953512007ae47e7a9f2f1de 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
async function main(url) { | |
const root = document.getElementById('root'); | |
root.innerHTML = 'Hello world'; | |
setTimeout(() => { | |
root.innerHTML = 'Something else'; | |
}, 2000); | |
root.addEventListener('click', () => { | |
root.innerHTML = 'You clicked root!'; | |
root.innerHTML = 'Hej Class!'; | |
}); | |
try { | |
const evt = await addEventPromise(root); | |
root.innerHTML = 'hello after await'; | |
} catch { | |
root.innerHTML = 'Error from catch'; | |
} | |
const promise = addEventPromise(root); | |
promise.then(evt => { | |
root.innerHTML = 'Hello from promise'; | |
}); | |
promise.then(evt => { | |
console.log('Hello from other promise then'); | |
}); | |
promise.catch(error => { | |
root.innerHTML = error.message; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment