stojan
05/10/2020, 8:54 AMval backgroundTask = IO.fx {
effect { Timber.d("starting sleep...") }.bind()
sleep(10.seconds).bind()
effect { Timber.d("sleep ended...") }.bind()
raiseError<Unit>(Throwable("Bang!!")).bind()
}
IO.fx {
effect { _viewState.postValue(ViewState.Loading) }.bind()
continueOn(Dispatchers.Default)
backgroundTask.fork().bind()
ViewState.Content(GithubService.model) // show static data
}
.handleError { ViewState.Error(it.errorMessage()) }
.flatMap { IO.effect { _viewState.postValue(it) } }
.unsafeRunScoped(viewModelScope) { }
if my ViewModel
gets destroyed here, the backgroundTask
continues executing (as expected). However after is done, the error is swallowed. Is that the expected behavior? 🤔simon.vergauwen
05/10/2020, 9:06 AMsimon.vergauwen
05/10/2020, 9:07 AMasync
without a CoroutineScope
.stojan
05/10/2020, 9:42 AMstojan
05/10/2020, 9:43 AMsimon.vergauwen
05/10/2020, 9:44 AMstojan
05/10/2020, 10:00 AMonErrorComplete
Otherwise it goes to the RxJava global error handler and my app blows up...simon.vergauwen
05/10/2020, 10:01 AMonError
handlers for IO
, and they take IO
actions instead of () -> Unit
simon.vergauwen
05/10/2020, 10:01 AMfireAndForget
operation that happened in a fiber to blow up your app by default?stojan
05/10/2020, 10:02 AMsimon.vergauwen
05/10/2020, 10:04 AMstojan
05/10/2020, 10:05 AMsimon.vergauwen
05/10/2020, 10:06 AMstojan
05/10/2020, 11:05 AMIn the case ofloosing it is not perfect, but having it delivered, which is the equivalent of `CoroutineScope.async`` would you expect that the error is send to anforkConnected
as well as stay inside theasyncErrorHandler
for when youFiber
it? So thejoin
would be guaranteed to show up once in theerror
on top of theasyncErrorHandler
times you canN
it?join
N
times ... not surestojan
05/10/2020, 11:07 AMstojan
05/10/2020, 11:07 AMstojan
05/10/2020, 11:09 AMfork
and throw away the cancellation token it means you don't care about the result, and if the result is error or success the behavior is the same....