Hayk
09/25/2024, 10:50 AMasync {}
block execute even if I didn't call await
on it? Shouldn't it actually start executing when I call await
? Or await
is just that it awaits for the execution to finish and doesn't mean that it shouldn't execute without await? Just without await
it becomes redundant and behaves like launch
not paying attention to the return type)Sam
09/25/2024, 10:58 AMasync
will start right away. There is an optional parameter you can pass to the async
function if you want to change that, though.Sam
09/25/2024, 10:59 AMawait
is just there so you can get the result (or exception, in case of failure). If you don't need a result, you're correct that you can just use launch
.Dmitry Khalanskiy [JB]
09/26/2024, 3:01 PMThere is an optional parameter you can pass to theIt's likely that you don't, though: https://github.com/Kotlin/kotlinx.coroutines/issues/4202 If you do, please let us know in the comments!function if you want to change that, though.async