kenkyee
11/16/2020, 10:28 PMlifecycleScope.launchWhenStarted {
how do you set an exception handler? There's no launchWhenStarted(errorHandler) version of this.
try/catch ex:Exception seems like too broad a thing to do...Zach Klippenstein (he/him) [MOD]
11/16/2020, 10:39 PMZach Klippenstein (he/him) [MOD]
11/16/2020, 10:40 PMwithContext(CoroutineExceptionHandler { }) { …
to also handle exceptions from child coroutineskenkyee
11/16/2020, 10:59 PMkenkyee
11/16/2020, 11:00 PMkenkyee
11/16/2020, 11:00 PMZach Klippenstein (he/him) [MOD]
11/16/2020, 11:31 PMZach Klippenstein (he/him) [MOD]
11/16/2020, 11:32 PMkenkyee
11/17/2020, 12:19 AMZach Klippenstein (he/him) [MOD]
11/17/2020, 12:41 AMlaunchWhenStarted
doesn’t take a CoroutineContext
, you can just wrap the body in withContext
like I mentioned above and it should do the same thing.Zach Klippenstein (he/him) [MOD]
11/17/2020, 12:42 AMlaunch
, you can certainly pass the CoroutineExceptionHandler
directly to launch
.kenkyee
11/17/2020, 12:43 AMZach Klippenstein (he/him) [MOD]
11/17/2020, 12:48 AMThrowable
, not just Exception
.bezrukov
11/17/2020, 5:53 AMwithContext
block and only can be used in two ways: as part of scope or part of context passed into launch/async. So it should be known at first coroutine builder pointbezrukov
11/17/2020, 5:54 AMJoost Klitsie
11/17/2020, 7:51 AMwhen(result) { is Success -> {} is Error -> {} is Loading-> {} }
I am more eager to handle all cases in the UI as well.Zach Klippenstein (he/him) [MOD]
11/17/2020, 3:39 PMbezrukov
11/17/2020, 3:55 PMbezrukov
11/17/2020, 3:55 PMcoroutineScope {
launch(ceh) {
}
}
will not work either. By detaching I mean creating a new Job without parent:
coroutineScope {
launch(Job() + ceh) {
}
}
should work, but it doesn't make much sense