I’m looking for an elegant way to log each case of an Either on my controller without going
when (either) {}
everywhere.
Any ideas?
w
Wesley Hartford
10/03/2022, 3:10 PM
Either.tap
and
Either.tapLeft
?
s
simon.vergauwen
10/04/2022, 12:38 PM
Yes,
tap
and
tapLeft
allow you to run a function and peek the value without adjusting the final result.
They're going to be renamed to
onRight
and
onLeft
in line with
Result#onSuccess
and
Result#onFailure
from Kotlin Std btw. Just plugging this here again in an attempt to get more feedback, this might also give you a better overview of the functionality available for Either @João Gabriel Zó.
https://github.com/arrow-kt/arrow/pull/2830