antonis
02/26/2019, 8:05 AMgildor
02/26/2019, 8:07 AMantonis
02/26/2019, 8:07 AMantonis
02/26/2019, 8:07 AMantonis
02/26/2019, 8:07 AMantonis
02/26/2019, 8:09 AMgildor
02/26/2019, 8:10 AMgildor
02/26/2019, 8:10 AMgildor
02/26/2019, 8:10 AMwithContext(<http://Dispatchers.IO|Dispatchers.IO>)
will work the same waygildor
02/26/2019, 8:12 AMantonis
02/26/2019, 8:13 AMsitepodmatt
02/26/2019, 8:14 AMantonis
02/26/2019, 8:14 AMantonis
02/26/2019, 8:15 AMsitepodmatt
02/26/2019, 8:19 AMantonis
02/26/2019, 8:23 AMantonis
02/26/2019, 8:24 AMsitepodmatt
02/26/2019, 8:31 AMgildor
02/26/2019, 8:32 AMthink withContext with will still trigger ambigious coroutineContext, will it not@sitepodmatt No, because no new coroutines are started, withContext doesn’t start new coroutines in scope, just a suspend function, so no ambigious context resolution, withContext always use context of suspend function
sitepodmatt
02/26/2019, 8:33 AMgildor
02/26/2019, 8:35 AMgildor
02/26/2019, 8:36 AMcoroutineScope
function that will create a new scope using suspend function context which allow you to run inside multiple child coroutines and coroutineScope
function suspend untill all child coroutines do not finish workgildor
02/26/2019, 8:37 AMsuspend fun searchWikipedia(): String {
return coroutineScope {
val result1 = async(<http://Dispatchers.IO|Dispatchers.IO>) { wikipedia(searchInput.text.toString()) }
val result2 = async(<http://Dispatchers.IO|Dispatchers.IO>) { wikipedia(searchInput2.text.toString()) }
result1.await() + result2.await()
}
}
antonis
02/26/2019, 8:53 AMantonis
02/26/2019, 8:56 PM