This commit is contained in:
Opeyemi Obembe 2018-10-13 08:30:44 +01:00 committed by GitHub
parent 9de36588a8
commit b16b26aad0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -133,7 +133,7 @@ let user = await response.json();
So we need to have a wrapping async function for the code that awaits. Just as in the example above. So we need to have a wrapping async function for the code that awaits. Just as in the example above.
```` ````
````smart header="`await` accepts thenables" ````smart header="`await` accepts thenables"
Like `promise.then`, `await` allows to use thenable objects (those with a callable `then` method). Again, the idea is that a 3rd-party object may be not a promise, but promise-compatible: if it supports `.then`, that's enough to use with `await`. Like `promise.then`, `await` allows to use thenable objects (those with a callable `then` method). Again, the idea is that a 3rd-party object may not be a promise, but promise-compatible: if it supports `.then`, that's enough to use with `await`.
For instance, here `await` accepts `new Thenable(1)`: For instance, here `await` accepts `new Thenable(1)`:
```js run ```js run