Cody Mikol
04/02/2021, 3:34 PMsuspend fun foo() = either {
val foo = !getFoo()
val bar = !getBar()
val foobar = !foobarFactory.make(foo, bar)
}
are foo
and bar
evaluated concurrently and then foobar
once its dependencies have resolved?
I’m trying to get a better overview of how arrow handles these suspended functions. Currently we are using either.eager
, but I’d like to better understand the non-blocking either
so I can benefit from that.simon.vergauwen
04/02/2021, 3:38 PMeither.eager
does.
The only difference between either.eager
and either
is that in the latter you can call suspend fun
from inside the { }
block.Cody Mikol
04/02/2021, 3:39 PMsimon.vergauwen
04/02/2021, 3:40 PMeither { }
like so.
suspend fun foo() = either {
val (foo, bar) = parZip(
{ getFoo().bind() },
{ getBar().bind() })
{ foo, bar -> Pair(foo, bar) }
val foobar = !foobarFactory.make(foo, bar)
}
Cody Mikol
04/02/2021, 4:04 PMCody Mikol
04/02/2021, 4:06 PM