Hexa
03/08/2019, 4:28 PMelizarov
03/09/2019, 9:43 AMelizarov
03/09/2019, 9:44 AMpardom
03/09/2019, 2:35 PMHexa
03/09/2019, 2:37 PMelizarov
03/09/2019, 2:39 PMHexa
03/09/2019, 2:39 PMHexa
03/09/2019, 2:39 PMHexa
03/09/2019, 2:39 PMHexa
03/09/2019, 2:39 PMelizarov
03/09/2019, 2:39 PMHexa
03/09/2019, 2:40 PMHexa
03/09/2019, 2:40 PMHexa
03/09/2019, 2:41 PMelizarov
03/09/2019, 2:41 PMHexa
03/09/2019, 2:42 PMHexa
03/09/2019, 2:42 PMelizarov
03/09/2019, 2:43 PMHexa
03/09/2019, 2:43 PMHexa
03/09/2019, 2:43 PMelizarov
03/09/2019, 2:44 PMHexa
03/09/2019, 2:44 PMelizarov
03/09/2019, 2:44 PMHexa
03/09/2019, 2:51 PMlaunch
?elizarov
03/09/2019, 2:51 PMasync
when you need result later, use launch
if you don’telizarov
03/09/2019, 2:52 PMcoroutineScope {
val a = async { loadA() }
val b = async { loadB() }
launch { save(a.await(), b.await()) }
}
elizarov
03/09/2019, 2:53 PMHexa
03/09/2019, 2:54 PMHexa
03/09/2019, 2:57 PMHexa
03/09/2019, 2:58 PMelizarov
03/09/2019, 2:58 PMasync { ... }
for the things you want to do concurrently, then await
them later. Don’t do async { ... }.await() ; async { ... }.await()
as it makes no sense — you don’t get any concurrency (you start the second one only when previous one completes)Hexa
03/09/2019, 3:01 PMelizarov
03/09/2019, 3:02 PMlaunch { ... }
for a side-effect. They will be automatically awaited at the end of your coroutineScope { ... }
elizarov
03/09/2019, 3:03 PMrunBlocking { ... }
if you top-level method must be blocking.elizarov
03/09/2019, 3:04 PM<http://Dispatchers.IO|Dispatchers.IO>
.elizarov
03/09/2019, 3:05 PMHexa
03/09/2019, 6:07 PMHexa
03/09/2019, 9:24 PMelizarov
03/10/2019, 6:13 AMelizarov
03/10/2019, 6:14 AM