Skip to content

Instantly share code, notes, and snippets.

@mattiaslundberg
Created August 21, 2019 09:05
Embed
What would you like to do?
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