Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / src/public-api / commit

Function: commit() ​

commit<T>(factory, maxRetries?, delay?): Stream<T>

Defined in: projects/libraries/streamix/src/lib/streams/commit.ts:26

Creates a transactional retrying stream that commits values only after a full attempt completes successfully.

Unlike retry, this operator buffers values produced during each attempt. If an attempt fails, the buffered values are discarded and the next retry starts from a clean state. When an attempt completes, its buffered values are emitted downstream in order.

This is useful when retries should preserve all-or-nothing visibility for a sequence, while retry itself remains pass-through.

Type Parameters ​

T ​

T = any

The type of values emitted by the source stream.

Parameters ​

factory ​

() => Stream<T> | MaybePromise<T>

A factory executed for each attempt. The produced result is normalized through fromAny, so it may be a stream, a promise, or a plain value.

maxRetries? ​

MaybePromise<number> = 3

The maximum number of retry operations allowed. A value of 0 runs a single attempt.

delay? ​

MaybePromise<number> = 1000

The delay window in milliseconds to pause between attempts.

Returns ​

Stream<T>

A stream that emits values only after an attempt finishes successfully.

Released under the GNU AGPL v3 or later.