Jorge Bo
11/18/2022, 12:43 PMeither<ReservationError, Unit> {
//do some logic
}.mapLeft {
meterService.incrementExitError("online")
it
}.map {
meterService.incrementExitRequests("online")
}
phldavies
11/18/2022, 12:49 PMsimon.vergauwen
11/18/2022, 1:12 PMguaranteeCase
or bracketCase
would work for this, but it's actually meant for other things.
That being said guaranteeCase
and bracketCase
(and Resource
) signal ExitCase.Cancelled
when calling bind()
on Either.Left
.
Why not just use also
?
either<ReservationError, Unit> {
}.also {
meterService.incrementExitRequests("online")
}
simon.vergauwen
11/18/2022, 1:14 PMguaranteeCase
or guarantee
would make more sense to me if you'd do something like this.
either {
guarantee({
Either.Left("error").bind()
}) { println("I always run") }
}
Jorge Bo
11/18/2022, 1:33 PM