@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
113 lines (78 loc) • 2.69 kB
Markdown
Provides properties that are used to execute synchronous or async functions.
You can use these properties in **params** of the [AuWidgetFunctionTrigger](../classes/auwidgetfunctiontrigger.md) class.
The following example illustrates how you can listen for property changes to execute a custom function.
```
{
"widgets": [
{
"name": "name",
"type": "option",
"params": {
"type": "list",
"title": "Name",
"prompt": "Choose a name",
"values": [
{ "title": "Jack" },
{ "title": "James" },
{ "title": "John" }
]
}
},
{
"name": "myFunction",
"type": "function-trigger",
"params": {
"arguments": [
"{{ $['name']._.title }}",
"{{ $['name']._.title }}"
],
"callback": [
"{{ #function(arg1, arg2) console.log(arg1, arg2) }}",
"{{ #asyncFunction await new Promise(...) }}"
]
"catch": [
"{{ #function console.error("failed") }}",
],
"finally": [
"{{ #function console.log("cleanup") }}",
]
}
}
]
}
```
* **IAuWidgetFunctionTriggerConfig**
* [arguments](iauwidgetfunctiontriggerconfig.md
* [callback](iauwidgetfunctiontriggerconfig.md
* [catch](iauwidgetfunctiontriggerconfig.md
* [enabled](iauwidgetfunctiontriggerconfig.md
* [finally](iauwidgetfunctiontriggerconfig.md
* [lock](iauwidgetfunctiontriggerconfig.md
• **arguments**: *Array‹string› | string*
An array of parameters change of which should trigger specified callbacks.
___
• **callback**: *Function | Array‹Function›*
A function `("{{#function <expression>}}")` or an array of functions that are executed when `arguments` parameter changes.
___
• **catch**: *Function | Array‹Function›*
A function `("{{#function <expression>}}")` or an array of functions that are executed if the `callback` fails.
___
• **enabled**: *boolean*
If `false`, the `callback` will not be executed. The default value is `true`.
___
• **finally**: *Function | Array‹Function›*
A function `("{{#function <expression>}}")` or an array of functions that are executed after the `callback`, regardless of its outcome.
___
• **lock**: *string[] | string*
The widget names that should be locked while waiting for the `callback`. The editor will show a preloader on this widget.