Class AuWidgetFunctionTrigger
A non-visual widget that is used to listen for property changes to execute custom functions. Can be used in other widgets. The following example illustrates how you can listen for property changes to execute custom functions.
{
"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") }}",
]
}
}
]
}
Package: ui-framework
Properties
enabled
If false, the callback will not be executed. The default value is true.
Declaration
public enabled: boolean = true
Property Value
| Type | Description |
|---|---|
| boolean | If |
params
Compiled widget configuration.
Declaration
params: any
Property Value
| Type | Description |
|---|---|
| any | Compiled widget configuration. |
template
Declaration
static HTMLTemplateElement template
Property Value
| Type | Description |
|---|---|
| HTMLTemplateElement |
Methods
checkInitDependenciesWidgets()
Returns an array of widget names, due to which the current widget cannot receive parameters.
Declaration
function checkInitDependenciesWidgets()
Returns
| Type | Description |
|---|---|
| string[] |
resetPreloaderState()
Declaration
function resetPreloaderState()
showPreloader(boolean, string | string[], number)
Shows a preloader.
"onClick": [
"{{#function main.showPreloader(true, 'Creating print files...')}}",
"{{#function $['editor'].getHiResImages(800,800)}}",
"{{#function main.showPreloader(false)}}"
]
Declaration
function showPreloader(isPreload: boolean, message: string | string[], timeout: number)
Parameters
| Type | Name | Description |
|---|---|---|
| boolean | isPreload |
If |
| string | string[] | message |
A text message that appears next to the preloader. |
| number | timeout |
showToast(string, number)
Shows a toast.
return editor.loadUserInfo(data)
.catch(err => {
this.widget.showToast("Error: Invalid data");
console.log(err);
});
Declaration
function showToast(data?: string, duration?: number)
Parameters
| Type | Name | Description |
|---|---|---|
| string | data |
A string message to display in the toast. |
| number | duration |
Defines how long to show the toast for. |