Oleh Havrysh
05/21/2019, 9:39 AMsuspendCoroutine
that doesn’t require passing result value?Oleh Havrysh
05/21/2019, 9:46 AMprivate suspend fun waitForPlayerOpen() {
suspendCoroutine<Unit> {
player.addOpenListener {
it.resume(Unit) //what if I don't need to return value?
}
}
}
But it still looks as workaround, isn’t it?gildor
05/21/2019, 9:46 AMgildor
05/21/2019, 9:46 AMOleh Havrysh
05/21/2019, 9:50 AMMelih Aksoy
05/21/2019, 10:02 AMit.resumeWith(Result.success)
? It’s still a return value but more meaningful.Oleh Havrysh
05/21/2019, 10:08 AMsuccess
is also function that takes value and wraps it into Result
, so I need to write it.resumeWith(Result.success(Unit))
. It almost the same as previous variantgildor
05/21/2019, 10:27 AMIt almost the same as previous variantIt’s exactly the same, function
resume
is juste extension function that wraps object to Result.successMelih Aksoy
05/21/2019, 1:07 PM