Skip to content

repeatUntil

repeatUntil<A>(options): (task) => Task<A>

Defined in: Core/Task.ts:282

Runs a Task repeatedly until the result satisfies a predicate, returning that result. An optional delay duration can be inserted between runs. An optional maxAttempts cap stops the loop after N calls — the last value is returned regardless of whether the predicate was satisfied.

A

Duration

number

(a) => boolean

(task) => Task<A>

pipe(
  checkStatus,
  Task.repeatUntil({ when: (s) => s === "ready", delay: Duration.milliseconds(500) })
)(); // polls every 500ms until status is "ready"