projectmoon
06/05/2019, 5:03 PMlauch { val result = async { doStuff() }.await() }
, assuming doStuff()
is a suspend fun? or would it make more sense to simply call doStuff()
inside the launch block without async
?Zach Klippenstein (he/him) [MOD]
06/05/2019, 5:20 PMdoStuff()
inside launch
, that async
isn’t doing anything.projectmoon
06/05/2019, 5:27 PMJason Ostrander
06/05/2019, 5:40 PMasync
is used when you want to run code in parallelasync
blocks, then await on both of the returned Deferredsprojectmoon
06/05/2019, 5:44 PMDico
06/05/2019, 6:20 PMasync
shouldnt be user very often at all, as a generale type of thumb.withContext
should commonly be used instead, when you invoke await
immediately anyway