3 ms·
async/await is a special case of monads (expressible with a for-comprehension); it comes out to: def asyncFunction(): Future[Blah] = for { foo <- someAsy
by azernik 9y ago
async/await is a special case of monads (expressible with a for-comprehension); it comes out to:
def asyncFunction(): Future[Blah] = for {
foo <- someAsynchronousOperation
bar <- anotherAsynchronousOperation
} yield bar.baz
- saosebastiao 9y agoI find async/await to be much better for conditional execution, especially with lots of branches. For example, I had a scenario where I tried one async call and if it didn't have the information I needed, I had to make two subsequent async calls to get the information I needed before proceeding with the final call. Monadic composition was a nightmare where async/await was perfectly suited to the task.
- clhodapp 9y agoFor comprehensions are currently tremendously limited vs async/await. They constrain the top-level of your code structure to a tiny subset of the language.