rednifre
07/09/2024, 5:35 PMgetFoo
returns a Result<GoodValue, ErrValue>
)
binding {
val goodValue = getFoo().bind()
}
The problem I have is that I can’t get it to work with coroutines:
This doesn’t compile, because getFoo()
is a suspend function, so I must call it from a coroutine scope
scope.launch {
binding {
val goodValue = getFoo().bind()
}
}
This crashes at runtime, because binding
apparently can’t catch the bind()
event (makes sense if it’s thrown asynchronously)
binding {
scope.launch {
val goodValue = getFoo().bind()
}
}
So how do I combine those?AdamW
07/09/2024, 5:44 PMbinding
?rednifre
07/09/2024, 6:23 PM