Created
June 5, 2015 19:04
-
-
Save bterlson/6ce9503b37685746ef27 to your computer and use it in GitHub Desktop.
Async constructors?
This file contains hidden or 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 Person() { | |
this.name = await getName(); | |
} | |
// seems weird-ish. | |
var p = new Person(); | |
p.then(person => console.log(person.name)); | |
// but seems better in another async function | |
async function CreatePerson() { | |
var person = await new Person(); | |
// ... | |
return person; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment