Created
March 11, 2019 17:38
-
-
Save mikeal/ce8ea81c6caff81bd74957ff0e7e5f74 to your computer and use it in GitHub Desktop.
async-ready
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
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