このページはまだ翻訳されていないため、英語で表示されます。 翻訳に参加する

rights, lefts & separated

Either-aware operators on an event chain of Either values — unwrap one side, or split both at once.

FxEvents<R> FxEvents<Either<L, R>>.rights() FxEvents<L> FxEvents<Either<L, R>>.lefts() (FxEvents<L> failures, FxEvents<R> successes) FxEvents<Either<L, R>>.separated()

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.

Related: Either × pipelines — the pull-side twins, plus sequence and flattenOrAccumulate · partitionseparated()'s predicate cousin · attempt — convert an error event so it counts once, on the failures half