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.

if you can use a React hook because you're writing a functional component, prefer useOperation over this component. Note: this component simply uses useOperation internally and renders its children as a function that receives the results from useOperation as an argument.

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. And prefer using the useOperation hook directly if possible, otherwise use this component.

Props

# Name Type Description
1. children Function

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

  • executeOperation: when called, executes the operation with the given operationName and operationData.

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

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

2. [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. Defaults to false.


  Default value
false
3. [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.)

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
4. operationName String

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

5. [operationData] Object

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

  Default value
{}
Was this page helpful?