Skip to content

Instantly share code, notes, and snippets.

@kpuputti
Created November 18, 2014 21:04
Show Gist options
  • Save kpuputti/99c7eadf925ffc37815b to your computer and use it in GitHub Desktop.
Save kpuputti/99c7eadf925ffc37815b to your computer and use it in GitHub Desktop.
Testing Flow.
/* @flow */
function wait(time: number): Promise<string> {
return new Promise((resolve, reject) => {
setTimeout(resolve.bind(null, 'resolved in ' + time + 'ms'), time);
});
}
document.addEventListener('DOMContentLoaded', () => {
console.log('start');
wait(1000).then((s) => {
console.log('got message:', s);
}, () => {
console.error('error');
});
console.log('stop');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment