Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The most frequently used kind of compound action is the every compound action. The every compound action takes every action listed in order. The actions are listed inside curly braces with semicolon separators:

Code Block
languagejavascript
themeConfluence
languagejavascript
if x > 5 then
  every {
    notify("Hello World!", "This is my first message!");
    notify("Hello Again!", "This is my second message!");
  }

...

Because this is so common, the keyword every is optional, and so this could be written as

warning
Code Block
languagejavascript
themeConfluencelanguagejavascript
if x > 5 then {
  notify("Hello World!", "This is my first message!");
  notify("Hello Again!", "This is my second message!");
}
titleParser Funk

The parser currently will accept multiple actions without enclosing them in braces. If you do this, only the last action will actually be taken.

There is no limit to the number of actions that can be placed inside a compound action. While there is no linguistic restriction on mixing actions that send JavaScript and those that send directives, no current endpoint understands both directives and JavaScript, so that is not typically done.

Choose

The other kind of compound action is the choose compound action. A choose action takes a list of actions like every, but instead of executing them all, it randomly picks one to execute. So, for example, the following would either send "This is one message!" or "This is another message!" randomly. The key reason for taking random action is to easily accommodate A/B behavior testing.

Code Block
languagejavascript
themeConfluencelanguagejavascript
if x > 5 then
  choose {
    notify("Hello World!", "This is one message!");
    notify("Hello World!", "This is another message!");
  }

The choose action can also be used to actually choose a specific action, like a case statement:

Code Block
languagejavascript
themeConfluencelanguagejavascript
choose some_var {
    A => notify("Hello World!", "This is one message!");
    B => notify("Hello World!", "This is another message!");
}

...