Understand Actions and Action Chains
An action chain is made up of one or more individual actions, each of which represents a single asynchronous unit of work. Action chains are triggered by events.
An action chain, like a variable, has a scope: it can be defined at the application level or the page level. You can call an application-scoped action chain from any page. You can call a page-scoped action chain only from the page on which it is defined.
To create an action chain, you can define your own actions and can also use predefined actions. Actions within a particular chain run serially, and multiple action chains can run concurrently. Action chains simplify the coordination of asynchronous activities.
A single event may simultaneously trigger multiple action chains. For example, the page enter event may trigger multiple data fetch action chains simultaneously.
An action is a specific function that performs a task. In JavaScript terms, an action is a Promise factory. An action can exist only within an action chain, not independently.
Action Chain Context and Contract
Action chains have a well-defined context and contract: an action chain orchestrates its underlying actions, coordinating state flow and the execution path. The action chain can define input parameters and local variables that are only available in that context. An example of an action chain is one that makes a REST call (first action), then takes the result of that and stores that in a variable (second action).
An action chain maintains its own context, which is accessible through an implicit object called $chain
. Actions may export new state to that context, but it is only available to future actions along that same action chain. An action chain can be created in the context of a page or the application and exists within the scope of the page or the application. It has a defined interface and contract and can be called by event triggers using its ID.
The action chain contract has three parts.
Action Chain Part | Description |
---|---|
ID | String identifier for the action chain |
Input parameters | Zero or more variables that can be passed into the action chain and added to the action chain context |
Variables | Zero or more variables that are internal to the action chain and usable internally by actions |
For more information, see Action Chains in the Oracle Visual Builder Studio Page Model Reference.
Built-in Actions
VB Studio comes with a set of built-in (or predefined) actions for an action chain, used for example navigation or assigning variable values. An action has the following parts that the developer can define:
Action Part | Description |
---|---|
ID | String identifier for this action instance. This action part is optional, since the ID is necessary only if you wish to refer to the action’s results later in the action chain. |
Configuration | Any properties of the action that the user can configure. For example, for the Navigate action, the page to navigate to and any parameters required for that navigation. |
Outcomes and Results | An action may have multiple potential outcomes (such as success or failure, or a branch). It can also return results. |
Exported State | An action may export state that is available to future actions within the context of the same action chain. |
The predefined actions include conditionals and other processing instructions. For example, you can use if
and switch
actions that take an expression and offer multiple different chain continuations depending on the result.
For details about predefined actions, see JavaScript Actionsin the Oracle Visual Builder Studio Page Model Reference.
Event Handling for Action Chains
Action chains are defined at the application or page level and triggered by a
specific event, such as onValueChange
(for a variable), or
vbEnter
. An event may include a payload, which can then be used within
the action chain. A payload may be passed into an action chain through the input parameters.
The VB Studio user interface can help you create
action chains automatically (with appropriate input parameters) based on a particular
event.