Saltar al contenido principal

Function: useRepeat()

useRepeat(callback, iterations, delayMs?): Promise<void>

Defined in: src/core/services/timing.service.ts:333

Executes a callback iterations times with an optional delay between each iteration.

Parameters

callback

(iteration) => void | Promise<void>

Function called on each iteration with the current index (0-based).

iterations

number

Number of times to repeat.

delayMs?

number = 0

Delay between iterations in milliseconds (defaults to 0).

Returns

Promise<void>

Example

await useRepeat((i) => console.log(`Attempt ${i + 1}`), 3, 1000);
// Attempt 1 ... (1s) ... Attempt 2 ... (1s) ... Attempt 3