addAction

How to get addAction

import addAction from 'fontoxml-operations/src/addAction.js'

Type: Function

Register an action to the set of globally usable actions. Actions change application state, without mutating the DOM. Examples of actions include saving the document, deleting references, etc.

Arguments

# Name Type Description
1. name String

The name of the action. Operations can invoke the action using a step of type "action/name".

2. run Function

Asynchronous callback function which defines the actual behavior of the action. Click on the type link to learn more.

Asynchronous callback function which defines the actual behavior of the action.

The callback receives the current operation StepData as the first and only argument. It should return nothing (undefined) or a addAction.CANCEL_OPERATION value to cancel the whole operation (under certain conditions). If your action is asynchronous, you can return a promise that eventually resolves into undefined or addAction.CANCEL_OPERATION.


  Arguments
# Name Type Description
1. stepData StepData
  Returns
3. [getState] Function

Optional asynchronous callback function which can be implemented to calculate the current state of operations using this action. Click on the type link to learn more.

Optional asynchronous callback function which can be implemented to calculate the current state of operations using this action. Useful if your action needs to manipulate the state of operations it is included in.

The callback receives the current operation StepData as the first and only argument. It should return the new OperationState. If determining the operation state is asynchronous, you can return a promise that eventually resolves into the new operation state.


  Arguments
# Name Type Description
1. stepData StepData
  Returns

Type: OperationState | Promise<OperationState>