Jimmy Alvarez
05/11/2021, 2:47 AMsimon.vergauwen
05/11/2021, 8:07 AMsuspend
.
For example, Arrow Fx has support for Schedule
and Flow
for retrying.
https://arrow-kt.io/docs/apidocs/arrow-fx-coroutines/arrow.fx.coroutines/kotlinx.coroutines.flow.-flow/retry.htmlJimmy Alvarez
05/11/2021, 4:58 PMsimon.vergauwen
05/11/2021, 5:54 PMFlow
to represent errors in the Throwable
domain. Just like suspend
.
It doesn't offer any utilities to model errors in a typed manner, that is where Either
comes in. It works the same whether you use suspend
or Flow
.
For example:
/** Returns a single [User] for a given [Id] or [UserNotFound] if [User] doesn't exist for [Id] *//
suspend fun fetchUser(id: Id): Either<UserNotFound, User> = TODO()
fun flowUsers(ids: Flow<Int>): Flow<Either<UserNotFound, User>> = ids.map { id -> fetchUser(id) }