rights, lefts & separated
Either-aware operators on an event chain of Either values — unwrap one side, or split both at once.
Lecture
Once a chain is FxEvents<Either<L, R>> —
from attempt or
mapEither —
these three operators are the push-side counterparts of
FxEitherOps.
rights() keeps only the successes, unwrapped;
lefts() keeps only the failures, unwrapped;
separated() splits into
(failures, successes) — the Either shape
of partition.
No terminals live here. pull() hands the chain to
FxAsync, where sequence() and
flattenOrAccumulate() already exist. These operators
stay in the events layer so a UI can listen to successes and
failures as two feeds.
separated() inherits partition's lifetime
rules: the record is returned eagerly, listening to either side
starts the source, cancelling both cancels it, and a value belonging
to a side nobody listens to is dropped rather than buffered.
It inherits partition's error fan-out too: an error
event is not an Either, so it goes to every
side currently listening — one upstream failure surfaces on both
halves. Call attempt upstream when a failure should be
counted once, as a Left on the failures
half.
Demo 1 · rights and lefts
Demo 2 · separated splits both halves
Try it yourself
Exercise: an error event fans out to both halves;
attempt upstream counts it once.
sequence and flattenOrAccumulate ·
partition — separated()'s predicate cousin ·
attempt — convert an error event so it counts once, on the failures half