Skip to main content

Function trigger

This non-visual widget is used to execute synchronous or async functions when the input parameters change.

General info

  • type: function-trigger

Params

  • arguments - an array of parameters, change of which should trigger specified callbacks.
  • callback - a function ("{{#function <expression>}}") or an array of functions that are executed when the arguments change.
  • catch - a function ("{{#function <expression>}}") or an array of functions that are executed if the callback fails.
  • enabled - if false, the callback will not be executed. The default value is true.
  • finally - a function ("{{#function <expression>}}") or an array of functions that are executed after the callback, regardless of its outcome.
  • lock - names of widgets that should be locked while waiting for the callback. The editor will display a preloader on this widget.

Example

Now, let's see how you can handle the result of selecting an option. Once an option is changed, the function-trigger widget will output its title to the console.

{
"widgets": [
{
"name": "options",
"type": "option",
"params": {
"type": "list",
"title": "Name",
"prompt": "Choose a name",
"values": [
{ "title": "Jack" },
{ "title": "James" },
{ "title": "John" }
]
}
},
{
"name": "option-titles",
"type": "function-trigger",
"enabled": false,
"lock": [],
"params": {
"arguments": [
"{{ $['options']._.title }}",
"{{ $['options']._.title }}"
],
"callback": [
"{{ #function(var1,var2) console.log(var1,var2) }}"
],
"catch": [
"{{ #function console.error('failed') }}"
],
"finally": [
"{{ #function console.log('cleanup') }}"
]
}
}
]
}

You can find more details about the properties of this widget in AuWidgetFunctionTrigger.

For more details about configuration parameters, refer to IAuWidgetFunctionTriggerConfig.

Was this page helpful?