Lukasz Kalnik
08/03/2022, 3:20 PMeither
over either.eager
for suspending computations?
If I use either.eager
, will it simply block the current thread?
suspend fun doSomethingLong(): Either<Error, Unit>
either.eager {
doSomethingLong() // does it block the current thread?
}
Sam
08/03/2022, 3:20 PMLukasz Kalnik
08/03/2022, 3:20 PMpublic final inline fun <E, A> eager(
crossinline f: suspend EagerEffectScope<E>.() → A
): Either<E, A>
simon.vergauwen
08/03/2022, 3:23 PMEagerEffectScope
is marked @RestrictSuspension
Lukasz Kalnik
08/03/2022, 3:24 PMsuspend
function, maybe that's the catchsimon.vergauwen
08/03/2022, 3:26 PMinline
so it uses the suspend
fro the outer scope.Lukasz Kalnik
08/03/2022, 3:26 PMsimon.vergauwen
08/03/2022, 3:27 PMsuspend
call?suspend
call inside eager
in your screenshotbind
but that should be coming from eager
Lukasz Kalnik
08/03/2022, 3:28 PMbind()
as the suspend function...simon.vergauwen
08/03/2022, 3:28 PMEagerEffectScope
so it’s alloweddelay(100)
should not be allowedLukasz Kalnik
08/03/2022, 3:29 PMeither
or either.eager
? I suppose not.
Or is there a reason why I should use either
, e.g. because my outer function is suspending anyway?simon.vergauwen
08/03/2022, 3:31 PM