Blocks that repeat a step#

For, Repeat, and Collect run a body of blocks once per item, then gather the results back up.

Looping blocks let a flow process more than one item in a single run. You feed a list or a count into a loop, run a body of blocks once per item, then gather the results. The category has three blocks: For, Repeat, and Collect.

For#

Iterates over a list and emits one item at a time. It has a List input for the array and a Start trigger, and an Item output. Wire a list-producing block into List, for example an array from an HTTP Request response, then chain Item into the body of the loop. The body runs once for each item.

Repeat#

Iterates by count when you have no list. It has a Count input and a Start trigger, and an Index output that emits the numbers from zero up to the count, not including the count itself. Set the count in the inspector. The default is 3.

Collect#

Gathers the results of a loop back into a single list. It has an Item input and two outputs, List and Finish. Wire the last block of the loop body into Item. When the loop ends, Collect emits the gathered array on List and fires the Finish trigger.

Wire a typical loop#

The usual pattern runs as follows.

  1. Produce a list, for example the response body of an HTTP Request that returns an array.
  2. Wire it into For's List port.
  3. Wire For's Item into the loop body.
  4. Wire the body's final block into Collect's Item.
  5. Read Collect's List for the aggregated result.