FxOperation

How to get FxOperation

import FxOperation from 'fontoxml-fx/src/FxOperation.jsx'

Type: Component

A children as a function component that can be used to get the operationState of the given operationName and/or execute it without using a specific FX component.

This component has been optimized for performance. This component and its API will probably remain intact for more (major) versions than the operationsManager. This component is more flexible, but also more verbose than using an FX component: FX components all use this component internally to couple operation state to a specific UI element like a Button.

So: Prefer using a specific FX component if one suffices. (Send us a signal if you're missing one.) Prefer using this component instead of using the operationsManager directly.

Props

# Name Type Description
1. props
2. [alwaysUpdateStateAfterMs] Number

Defaults to 3000. Used for performance micro optimization. Don't change this if you're not really sure you want to and think you need it. (In the SDK, for Fx components, this is not changed at all.) Never make this smaller than the value for onlyUpdateStateAgainAfterMs.

The operation state change notifier from the operationsManager can fire multiple times in quick succession in certain cases, without the state actually changing. To prevent multiple re-renders in quick succession that do not render anything new (the state didn't change) the notifier callbacks are windowed.

This property controls the number of ms since the last render after which another render takes place. This is not an exact amount of ms but a minimum amount. The check for this value only happens every onlyUpdateStateAgainAfterMs.


  Default value
3000
3. children Function

Returns an object with the following properties, all related to the given operationName:

  • executeOperation: a function to execute the given operation. You can pass additional operationData to this function as well (or use the operationData prop, or both, were the operationData given to this function is leading). Returns the promise from operationsManager.executeOperation.

  • operation: the operation (config) as it is defined in operations.json

  • operationState: the current operationState (an object with active/enabled booleans)

4. [focusEditorWhenDone] Boolean

Whether or not the editor (content view) should be focused after the operation with the given operationName is executed (using executeOperation as given to the children function of this component). This will not apply for other executions of the operation, outside of this component.


  Default value
false
5. [onlyUpdateStateAgainAfterMs] Number

Defaults to 300. Used for performance micro optimization. Don't change this if you're not really sure you want to and think you need it. (In the SDK, for Fx components, this is not changed at all.) Never make this larger than the value for alwaysUpdateStateAfterMs.

The operation state change notifier from the operationsManager can fire multiple times in quick succession in certain cases, without the state actually changing. To prevent multiple re-renders in quick succession that do not render anything new (the state didn't change) the notifier callbacks are windowed.

This property controls the number of ms during which all successive notifier callbacks are windowed: meaning, during this time, nothing will happen directly when the notifier callback fires. Instead a timeout is set for this duration that is cleared whenever a new notifier callback is fired. If the timeout expires, a re-render is triggered with the latest operationState at the moment of rendering.


  Default value
300
6. operationName String

The name by with the operation was registered. The component will be replaced with a CompactStateMessage if the operation is not found.

7. [operationData] Object

Additional operation data, which will be added to the stepData of the operation.

  Default value
{}