Kulwinder Singh
11/04/2018, 9:47 AMinit
and getLastState
are suspend
function ?louiscad
11/04/2018, 9:52 AMasync
and await
.Kulwinder Singh
11/04/2018, 9:55 AMasync { musicProvider.init() }.await()
val lastState = async { musicProvider.getLastState() }.await()
louiscad
11/04/2018, 10:10 AMval lastStateAsync = async { musicProvider.getLastState() }
musicProvider.init()
val lastState = lastStateAsync.await()
Daniel Tam
11/04/2018, 10:50 AMlistOf(
async { ... },
async { ... }
).awaitAll()
getLastState
, and since async calls now work intuitively with their parent scope if they throwbdawg.io
11/04/2018, 11:04 PMinit
? (By result I mean was there an exception). If not, just launch that and then use getLastState
directly uiScope.launch {
launch { runCatching { musicProvider.init() } }
val lastState = musicProvider.getLastState()
...
}