Skip to content

Repeat

Name Mandatory Description Default Type
⬅️ Input The input will be passed to both the action and the Until condition if used. Any
Output ➡️ The output of this shard will be its input. Any
Action No The shards to repeat. none Shard[Shard]
Times No How many times we should repeat the action. none IntVar(Int)None
Forever No If we should repeat the action forever. false Bool
Until No Optional shards to use as predicate to continue repeating until it's true none Shard[Shard]None

Repeat an action a given number of times or until the 'Until' parameter returns true.

Examples

1
2
3
4
5
6
7
8
9
0 >= n
Repeat({
  Msg("Hello")
} Times: 5)

Repeat({
  n | Log("Counting")
  Math.Inc(n)
} Until: {n | IsMore(9)})

[info] [sample-wire] Hello
[info] [sample-wire] Hello
[info] [sample-wire] Hello
[info] [sample-wire] Hello
[info] [sample-wire] Hello
[info] [sample-wire] Counting: 0
[info] [sample-wire] Counting: 1
[info] [sample-wire] Counting: 2
[info] [sample-wire] Counting: 3
[info] [sample-wire] Counting: 4
[info] [sample-wire] Counting: 5
[info] [sample-wire] Counting: 6
[info] [sample-wire] Counting: 7
[info] [sample-wire] Counting: 8
[info] [sample-wire] Counting: 9