StreamX<T> extension

General-purpose utility extension on Stream providing enhanced filtering, timing controls (like debounce/throttle), error handling, and scanning operators.

on

Properties

indexed Stream<(int, T)>

Available on Stream<T>, provided by the StreamX extension

Emits (index, value) pairs — like enumerate in Python.
no setter
pairwise Stream<(T, T)>

Available on Stream<T>, provided by the StreamX extension

Pairs each event with the previous one as (previous, current). Skips the first event (no previous exists).
no setter

Methods

debounce(Duration duration) Stream<T>

Available on Stream<T>, provided by the StreamX extension

Suppresses events that arrive within duration of each other, emitting only the last one in each quiet window (debounce).
distinctUntilChanged([bool equals(T, T)?]) Stream<T>

Available on Stream<T>, provided by the StreamX extension

Emits only values that differ from the previous emission. Optionally compare by a derived key instead of the value itself.
lastOrNull() Future<T?>

Available on Stream<T>, provided by the StreamX extension

Emits the stream's last value as a Future, or orElse if the stream closes empty.
onErrorReturn(T fallback) Stream<T>

Available on Stream<T>, provided by the StreamX extension

Recovers from errors by emitting fallback.
onErrorReturnWith(T recover(Object error)) Stream<T>

Available on Stream<T>, provided by the StreamX extension

Recovers from errors by emitting the result of recover.
scan<S>(S seed, S accumulate(S acc, T value)) Stream<S>

Available on Stream<T>, provided by the StreamX extension

Accumulates state across events using seed and accumulate.
skipUntil(bool predicate(T)) Stream<T>

Available on Stream<T>, provided by the StreamX extension

Discards events until predicate returns true, then emits all subsequent ones.
takeWhileInclusive(bool predicate(T)) Stream<T>

Available on Stream<T>, provided by the StreamX extension

Emits events only while predicate holds; closes the stream on first failure.
throttle(Duration duration) Stream<T>

Available on Stream<T>, provided by the StreamX extension

Emits the first event of each duration window and suppresses the rest (throttle).
whereNotNull<R extends Object>() Stream<R>

Available on Stream<T>, provided by the StreamX extension

Emits only non-null values, narrowing the type to R.