Satyam Agarwal
11/29/2020, 9:48 AMeither {
val (value1, value2) = parTupleN(
suspend { someMethodReturningEither() },
suspend { someMethodReturningEither() }
)
.right()
.flatMap { (first, second) -> first.mproduct { second } }
.bind()
val (value1, value2) = parTupleN(
suspend { someMethodReturningEither().bind() },
suspend { someMethodReturningEither().bind() }
)
}
Is there a difference between the two in terms of how parallelism will be done ?
This question is because how I was used to do parTupledN
with IO
.
There the results were always flatMapped and used to give IO<Tuple2<A, B>>
raulraja
11/29/2020, 9:51 AMraulraja
11/29/2020, 9:53 AMSatyam Agarwal
11/29/2020, 9:53 AMarrow-fx-coroutines
Satyam Agarwal
11/29/2020, 9:54 AMval (value1, value2) = parTupleN(
suspend { someMethodReturningEither().bind() },
suspend { someMethodReturningEither().bind() }
)
is exactly same as
val (value1, value2) = parTupleN(
suspend { someMethodReturningEither() },
suspend { someMethodReturningEither() }
)
.right()
.flatMap { (first, second) -> first.mproduct { second } }
.bind()
with no change one how these methods will be executed with coroutines ?raulraja
11/29/2020, 9:55 AMraulraja
11/29/2020, 9:56 AMSatyam Agarwal
11/29/2020, 9:58 AMval (value1, value2) = parTupleN(
suspend { someMethodReturningEither().bind() },
suspend { someMethodReturningEither().bind() }
)
Is much simpler approach than the other one right ?
Also flatMap will be gone ? 😢Satyam Agarwal
11/29/2020, 9:59 AMraulraja
11/29/2020, 9:59 AMSatyam Agarwal
11/29/2020, 10:00 AMeither
block, as it is less code, no pyramid and neatSatyam Agarwal
11/29/2020, 10:00 AMraulraja
11/29/2020, 10:02 AMSatyam Agarwal
11/29/2020, 10:02 AMSatyam Agarwal
11/29/2020, 10:09 AM