Search
Loading...
Skip to content

Class: ActionsAPI

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

Methods#

register()#


Registers a custom action for a specific event type.

Type Parameters#

Type Parameter
T extends ActionId

Parameters#

ParameterTypeDescription
actionIdTThe event type to register an action for
actionActionFunction<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 ParameterDefault type
T extends ActionId-
CCustomActionFunction

Parameters#

ParameterTypeDescription
actionIdTThe 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 ParameterDefault type
T extends ActionId-
CCustomActionFunction

Parameters#

ParameterTypeDescription
actionIdTThe event type to execute
argsActionFunction<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>