async support
Closed this issue · 1 comments
hilljh82 commented
JavaScipt has the concept of async/await. One of the main advantages of async/await is it removes the dreaded promise chaining. Here is example code using async/await
const users = await downloadUsers ();
In the example above, downloadUsers()
returns a Promise
. The await
keyword causes the calling thread to block while the function the Promise
returned from downloadUsers()
is settled. If the promises resolves, then the resolved value is returned. If the promises is rejected, then it throws an exception.
We should provide the same concept with this library, and we can. I envision something like the following:
import static Promise.await;
final Users users = await (downloadUsers ());
If the promise resolves, then it returns the users. If the promise is rejected, then an exception is thrown.
hilljh82 commented
This feature is now available.