ActionsAPI provides a centralized way to manage and customize actions for various user interactions in the Creative Engine SDK.
This API allows you to:
- Register custom actions for events (export, load, download, etc.)
- Use default implementations when no custom action is registered
- Maintain consistent behavior across different UI components
Constructors#
Constructor#
ActionsAPI
ActionsAPIMethods#
register()#
Registers a custom action for a specific event type.
Type Parameters#
| Type Parameter |
|---|
T extends ActionId |
Parameters#
| Parameter | Type | Description |
|---|---|---|
actionId | T | The event type to register an action for |
action | ActionFunction<T> | The custom action function |
Returns#
void
Example#
actionsAPI.register('downloadFile', async (blob, mimeType) => { // Custom download logic await customDownloadAction(blob, mimeType);});Signature#
register(actionId: T, action: ActionFunction<T>): voidget()#
Returns the custom export video action if registered, otherwise returns the default.
Type Parameters#
| Type Parameter | Default type |
|---|---|
T extends ActionId | - |
C | CustomActionFunction |
Parameters#
| Parameter | Type | Description |
|---|---|---|
actionId | T | The event type to get an action for |
Returns#
ActionFunction<T, C>
Example#
const exportAction = actionsAPI.get('export');if (exportAction) { const result = await exportAction(options);}Signature#
get(actionId: T): ActionFunction<T, C>run()#
Executes a registered action with the provided parameters.
Throws an error if the action is not registered.
Type Parameters#
| Type Parameter | Default type |
|---|---|
T extends ActionId | - |
C | CustomActionFunction |
Parameters#
| Parameter | Type | Description |
|---|---|---|
actionId | T | The event type to execute |
…args | ActionFunction<T, C> extends CustomActionFunction ? Parameters<ActionFunction<ActionFunction<T, C>>> : never[] | The arguments to pass to the action |
Returns#
Promise<ActionFunction<T, C> extends (…args) => R ? R : never>
The result of the action execution
Throws#
Error if the action is not registered
Example#
try { const result = await actionsAPI.run('exportDesign', exportOptions); console.log('Export completed', result);} catch (error) { console.error('Export action not registered');}Signature#
run(actionId: T, args: ActionFunction<T, C> extends CustomActionFunction ? Parameters<ActionFunction<ActionFunction<T, C>>> : never[]): Promise<ActionFunction<T, C> extends (args: any[]) => R ? R : never>list()#
Returns all registered action IDs.
This method retrieves a list of all action identifiers that are available.
Parameters#
| Parameter | Type | Description |
|---|---|---|
options? | { matcher?: string; } | Optional configuration object with the following properties: - matcher: Optional pattern to match against. Use * for wildcard matching. |
options.matcher? | string | - |
Returns#
ActionId[]
An array of action IDs currently registered in the store
Example#
const registeredActions = actionsAPI.list();console.log('Available actions:', registeredActions);// Output: ['saveScene', 'exportDesign', 'customAction1', ...]
// Find all export-related actions using wildcardconst exportActions = actionsAPI.list({ matcher: 'export*' });console.log('Export actions:', exportActions);// Output: ['exportDesign', 'exportScene', ...]Signature#
list(options?: object): ActionId[]