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 PMLukasz Kalnik
08/03/2022, 3:21 PMpublic final inline fun <E, A> eager(
crossinline f: suspend EagerEffectScope<E>.() → A
): Either<E, A>simon.vergauwen
08/03/2022, 3:23 PMsimon.vergauwen
08/03/2022, 3:23 PMEagerEffectScope is marked @RestrictSuspensionLukasz 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 PMLukasz Kalnik
08/03/2022, 3:26 PMLukasz Kalnik
08/03/2022, 3:26 PMsimon.vergauwen
08/03/2022, 3:27 PMsimon.vergauwen
08/03/2022, 3:27 PMsuspend call?simon.vergauwen
08/03/2022, 3:27 PMsuspend call inside eager in your screenshotsimon.vergauwen
08/03/2022, 3:27 PMbind but that should be coming from eagerLukasz Kalnik
08/03/2022, 3:28 PMbind() as the suspend function...simon.vergauwen
08/03/2022, 3:28 PMEagerEffectScope so it’s allowedsimon.vergauwen
08/03/2022, 3:28 PMdelay(100) should not be allowedLukasz Kalnik
08/03/2022, 3:29 PMLukasz Kalnik
08/03/2022, 3:29 PMLukasz Kalnik
08/03/2022, 3:30 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