Skip to content

Instantly share code, notes, and snippets.

@mikeal
Created March 11, 2019 17:38
Show Gist options
  • Save mikeal/ce8ea81c6caff81bd74957ff0e7e5f74 to your computer and use it in GitHub Desktop.
Save mikeal/ce8ea81c6caff81bd74957ff0e7e5f74 to your computer and use it in GitHub Desktop.
async-ready
class NeedsReady {
constructor () {
this.ready = new Promise(resolve => setTimeout(resolve, 1000))
}
async foo () {
await this.ready
return 'bar'
}
}
// usage
let n = new NeedsReady()
let result = await n.foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment