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
ActionsAPI
Methods#
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>): void
get()#
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>