asyncFoldExhaust<S, A> static method
Similar to asyncFold, but ignores new triggers while an inner accumulation is already running.
When to use
Use asyncFoldExhaust when you want to prevent overlapping state updates.
- Submit Buttons: Preventing multiple form submissions from corrupting the accumulated state.
- Resource Locking: Ensuring a state update finishes before accepting the next.
How it works
- The first incoming pulse starts the
accumulatefunction. - While the accumulation is running, new triggers are dropped.
- When the accumulation completes, the next trigger is accepted.
Implementation
static FlowHandle asyncFoldExhaust<S, A>(
Cell source, {
required A seed,
required FutureOr<A> Function(A acc, S value) accumulate,
FoldSnapshot<A>? snapshot,
FoldErrorHandler? onError,
}) {
return AsyncFoldExhaust<S, A>(
seed,
accumulate,
snapshot: snapshot,
onError: onError,
).toHandle(source: source);
}