@revideo/core / flow / loop
Function: loop()
Call Signature
loop(
factory):ThreadGenerator
Defined in: flow/loop.ts:61
Run the given generator in a loop.
Parameters
factory
A function creating the generator to run. Because generators can’t be reset, a new generator is created on each iteration.
Returns
Remarks
Each iteration waits until the previous one is completed.
Because this loop never finishes it cannot be used in the main thread.
Instead, use yield or threading.spawn to run the loop concurrently.
Example
Rotate the rect indefinitely:
yield loop(
() => rect.rotation(0).rotation(360, 2, linear),
);Call Signature
loop(
iterations,factory):ThreadGenerator
Defined in: flow/loop.ts:88
Run the given generator N times.
Parameters
iterations
number
The number of iterations.
factory
A function creating the generator to run. Because generators can’t be reset, a new generator is created on each iteration.
Returns
Remarks
Each iteration waits until the previous one is completed.
Example
const colors = [
'#ff6470',
'#ffc66d',
'#68abdf',
'#99c47a',
];
yield* loop(
colors.length,
i => rect.fill(colors[i], 2),
);