Executes an algorithm or ILayoutAlgorithm on a graph asynchronously and optionally animates the transition to the new layout, afterward.
Remarks
In contrast to LayoutExecutor, this class serves as one half of the pair of two classes that perform the calculation in separate contexts, asynchronously to the main thread that starts the layout. This allows the main thread to continue and the UI to stay responsive when longer layout calculations need to be performed, or multiple layout calculations should be carried out in parallel.
Instances of this class will serialize all the information that is required to execute the algorithm and send that information to a separate context, which processes the data with the help of the LayoutExecutorAsyncWorker class. The context that worker executes in often is a Web Worker, but it could also be running on a different machine or a server.
The actual transmission of the serialized data to the other context is not part of this implementation. Rather, it can be added by means of passing a function callback to the constructor. That function will be given an opaque blob that can be serialized and sent to the second context where it will be processed by a call to process. Once the the response is received from the other context, the function callback resolves the Promise
and the results are applied to the graph.
Related Reading in the Developer's Guide
Type Details
- yFiles module
- view-layout-bridge
See Also
Constructors
LayoutExecutorAsync
(messageHandler: function(object):Promise<object>, graphComponent: GraphComponent, layoutDescriptor?: LayoutDescriptor, layoutData?: LayoutData<INode,IEdge,ILabel,ILabel>)Creates a new instance of a layout execution helper that will asynchronously perform the calculations and optionally animate the layout on the given graphComponent
.
Remarks
messageHandler
will be given the serialized information to pass to the layout worker. Once the worker returns the results, the handler will need to resolve the Promise
and the results will be deserialized and applied to the graph. If you don't have a GraphComponent, use the constructor variant that takes the IGraph, instead.Parameters
A map of options to pass to the method.
- messageHandler - function(object):Promise<object>
The function that will send the data to the remote worker. It's an asynchronous function that will need to resolve it's
Promise
once it receives the processed data from the worker. The parameter passed to (and returned from) the function is JSON serializable and structurally cloneable . Otherwise, the contents of the data blob are considered an implementation detail and may change at any time between releases.When no additional data has to be passed between the threads, the convenience method createWebWorkerMessageHandler can be used to create the message handler.
Signature Details
function(data: object) : Promise<object>
Implements message passing between two contexts.LayoutExecutorAsync uses this function to senddata
to the LayoutExecutorAsyncWorker. After the worker has performed its task, it will send back the results and the need to be returned (resolved via thePromise
) to the calling code. Implementations can expect the values to be JSON serializable and structurally cloneable . Otherwise, the contents of the data blob are considered an implementation detail and may change at any time between releases.Parameters
- data - object
- The data to send to the
method in the worker context.
Returns
- Promise<object>
- A
Promise
that will resolve to the data received from the worker context.
- graphComponent - GraphComponent
- layoutDescriptor - LayoutDescriptor
- The optional descriptor to serialize and send to the worker. This property can later be set and reset via the layoutDescriptor property.
- layoutData - LayoutData<INode,IEdge,ILabel,ILabel>
- The optional data that is associated with the graph items that needs to be transferred to the worker. This property can also later be set and reset via the layoutData property.
- anchoredItems - ItemMapping<IModelItem,LayoutAnchoringPolicy>
- The mapping of graph items to LayoutAnchoringPolicy values, specifying which part of the items should be used to anchor the graph during layout. This option either sets the value directly or recursively sets properties to the instance of the anchoredItems property on the created object.
- configureTableLayout - boolean
- A value indicating whether to automatically perform calls to prepare and restore in order to layout table nodes. This option sets the configureTableLayout property on the created object.
- animationDuration - TimeSpan
- The duration of the animation. This option sets the animationDuration property on the created object.
- labelPlacementPolicies - ItemMapping<ILabel,LabelPlacementPolicy>
- A mapping that specifies how ILabels should be placed by the layout algorithm. This option either sets the value directly or recursively sets properties to the instance of the labelPlacementPolicies property on the created object.
- portPlacementPolicies - ItemMapping<IPort,PortPlacementPolicy>
- A mapping that specifies how IPorts should be placed by the layout algorithm. This option either sets the value directly or recursively sets properties to the instance of the portPlacementPolicies property on the created object.
- animateViewport - boolean
- A value indicating whether the viewport should be animated to the new bounds of the graph. This option sets the animateViewport property on the created object.
- considerViewportLimiter - boolean
- A value indicating whether to respect the viewportLimiter of the GraphComponent of this instance. This option sets the considerViewportLimiter property on the created object.
- easedAnimation - boolean
- A value indicating whether to use eased animation. This option sets the easedAnimation property on the created object.
- targetBoundsPadding - Insets
- The padding (in world coordinates) that will be added to the content bounds when calculating the target viewport. This option sets the targetBoundsPadding property on the created object.
- updateContentBounds - boolean
- A value indicating whether the contentBounds property of the graphComponent should be updated upon completion. This option sets the updateContentBounds property on the created object.
- allowUserInteraction - boolean
- A value indicating whether user interaction should be allowed during the execution and animation. This option sets the allowUserInteraction property on the created object.
- portLabelPolicies - ItemMapping<ILabel,PortLabelPolicy>
- How ILabels at IPorts should be treated by the layout algorithm. This option either sets the value directly or recursively sets properties to the instance of the portLabelPolicies property on the created object.
- edgePortNodeSize - Size
- The size of the nodes that are inserted for the ports that are created for IEdges that are connected at other IEdges. This option sets the edgePortNodeSize property on the created object.
- hideEdgesAtEdges - boolean
- A value that controls whether edges at other edges will be hidden from the layout graph or included. This option sets the hideEdgesAtEdges property on the created object.
- portAdjustmentPolicies - ItemMapping<IPort,PortAdjustmentPolicy>
- The mapping from ports to a policy that specifies how port locations should be adjusted after a layout has been calculated. This option either sets the value directly or recursively sets properties to the instance of the portAdjustmentPolicies property on the created object.
- nodeComparator - function(INode, INode):number
- A comparison function that normalizes the order of the nodes for the layout calculation to ensure the same order for multiple layout invocations. This option sets the nodeComparator property on the created object.
- edgeComparator - function(IEdge, IEdge):number
- A comparison function that normalizes the order of the edges for the layout calculation to ensure the same order for multiple layout invocations. This option sets the edgeComparator property on the created object.
- sequentialExecution - boolean
- A value indicating whether this instance waits for other instances to finish their operations before it executes. This option sets the sequentialExecution property on the created object.
- cancelDuration - TimeSpan
- The duration a layout may run before being cancelled automatically. This option sets the cancelDuration property on the created object.
- stopDuration - TimeSpan
- The duration a layout may run before being stopped automatically. This option sets the stopDuration property on the created object.
LayoutExecutorAsync
(messageHandler: function(object):Promise<object>, graph: IGraph, layoutDescriptor?: LayoutDescriptor, layoutData?: LayoutData<INode,IEdge,ILabel,ILabel>)Creates a new instance of a layout execution helper that will asynchronously perform the calculations and apply the results on the provided graph
.
Remarks
messageHandler
will be given the serialized information to pass to the layout worker. Once the worker returns the results, the handler will need to resolve the Promise
and the results will be deserialized and applied to the graph.Parameters
A map of options to pass to the method.
- messageHandler - function(object):Promise<object>
The function that will send the data to the remote worker. It's an asynchronous function that will need to resolve it's
Promise
once it receives the processed data from the worker. The parameter passed to (and returned from) the function is JSON serializable and structurally cloneable . Otherwise, the contents of the data blob are considered an implementation detail and may change at any time between releases.When no additional data has to be passed between the threads, the convenience method createWebWorkerMessageHandler can be used to create the message handler.
Signature Details
function(data: object) : Promise<object>
Implements message passing between two contexts.LayoutExecutorAsync uses this function to senddata
to the LayoutExecutorAsyncWorker. After the worker has performed its task, it will send back the results and the need to be returned (resolved via thePromise
) to the calling code. Implementations can expect the values to be JSON serializable and structurally cloneable . Otherwise, the contents of the data blob are considered an implementation detail and may change at any time between releases.Parameters
- data - object
- The data to send to the
method in the worker context.
Returns
- Promise<object>
- A
Promise
that will resolve to the data received from the worker context.
- graph - IGraph
- The graph that will be serialized and transferred to the worker.
- layoutDescriptor - LayoutDescriptor
- The optional descriptor to serialize and send to the worker. This property can later be set and reset via the layoutDescriptor property.
- layoutData - LayoutData<INode,IEdge,ILabel,ILabel>
- The optional data that is associated with the graph items that needs to be transferred to the worker. This property can also later be set and reset via the layoutData property.
- cancelDuration - TimeSpan
- The duration a layout may run before being cancelled automatically. This option sets the cancelDuration property on the created object.
- stopDuration - TimeSpan
- The duration a layout may run before being stopped automatically. This option sets the stopDuration property on the created object.
- labelPlacementPolicies - ItemMapping<ILabel,LabelPlacementPolicy>
- A mapping that specifies how ILabels should be placed by the layout algorithm. This option either sets the value directly or recursively sets properties to the instance of the labelPlacementPolicies property on the created object.
- configureTableLayout - boolean
- A value indicating whether to automatically perform calls to prepare and restore in order to layout table nodes. This option sets the configureTableLayout property on the created object.
- portAdjustmentPolicies - ItemMapping<IPort,PortAdjustmentPolicy>
- The mapping from ports to a policy that specifies how port locations should be adjusted after a layout has been calculated. This option either sets the value directly or recursively sets properties to the instance of the portAdjustmentPolicies property on the created object.
- portPlacementPolicies - ItemMapping<IPort,PortPlacementPolicy>
- A mapping that specifies how IPorts should be placed by the layout algorithm. This option either sets the value directly or recursively sets properties to the instance of the portPlacementPolicies property on the created object.
- portLabelPolicies - ItemMapping<ILabel,PortLabelPolicy>
- How ILabels at IPorts should be treated by the layout algorithm. This option either sets the value directly or recursively sets properties to the instance of the portLabelPolicies property on the created object.
- edgePortNodeSize - Size
- The size of the nodes that are inserted for the ports that are created for IEdges that are connected at other IEdges. This option sets the edgePortNodeSize property on the created object.
- hideEdgesAtEdges - boolean
- A value that controls whether edges at other edges will be hidden from the layout graph or included. This option sets the hideEdgesAtEdges property on the created object.
- anchoredItems - ItemMapping<IModelItem,LayoutAnchoringPolicy>
- The mapping of graph items to LayoutAnchoringPolicy values, specifying which part of the items should be used to anchor the graph during layout. This option either sets the value directly or recursively sets properties to the instance of the anchoredItems property on the created object.
Properties
Gets or sets a value indicating whether user interaction should be allowed during the execution and animation.
Remarks
If false
, the WaitInputMode is queried from the CanvasComponent and waiting is enabled during the animation.
The default value is false
.
Gets or sets the mapping of graph items to LayoutAnchoringPolicy values, specifying which part of the items should be used to anchor the graph during layout.
Remarks
This property anchors the graph on an initial position based on either a single graph item or the alignment of the bounds of several items (but not the positions of the individual items).
The default LayoutAnchoringPolicy for all items is NONE, meaning items are not anchored unless explicitly specified.
Examples
Use the bounds of all items to anchor the graph, ensuring that the overall structure remains stable:
const layout = new HierarchicalLayout()
await new LayoutExecutor({
graphComponent: graphComponent,
layout: layout,
anchoredItems: LayoutAnchoringPolicy.BOUNDS,
}).start()
Alternatively, anchor the graph using the location of a single item. In this example, the upper-left corner of a node is fixed. This is particularly useful when recalculating the layout for scenarios like expanding or collapsing a group node. To provide a seamless user experience, the group node itself remains in the same position, ensuring that the expand/collapse button stays directly under the mouse pointer:
const layout = new HierarchicalLayout()
await new LayoutExecutor({
graphComponent: graphComponent,
layout: layout,
anchoredItems: (item) =>
item === fixedNode
? LayoutAnchoringPolicy.LOWER_LEFT
: LayoutAnchoringPolicy.NONE,
}).start()
Gets or sets a value indicating whether the viewport should be animated to the new bounds of the graph.
Remarks
The result when this property is true
after the animation is the same as calling fitGraphBounds. Setting this property to true
and changing animationDuration to ZERO will disable the animation, but still change the viewport to the new graph bounds.
When the viewport should stay the same, the layout algorithms often have to be coerced to keep parts of the graph in the same location. This can be done by wrapping the layout algorithm in an instance of LayoutAnchoringStage.
The default value is true
.
Property Value
true
if the viewport should be animated; false
otherwise.Gets or sets the duration a layout may run before being cancelled automatically.
Remarks
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the duration is negative
See Also
Gets or sets a value indicating whether to respect the viewportLimiter of the GraphComponent of this instance.
Remarks
true
, but as updating the layout typically also updates the contentBounds, depending on the ViewportLimiter implementation and configuration, this could be set to false
, instead.Property Value
Gets or sets a comparison function that normalizes the order of the edges for the layout calculation to ensure the same order for multiple layout invocations.
Remarks
Among other factors, the results produced by layout algorithms usually depend on the order of the nodes and edges within a graph. Unfortunately, useful operations such as hiding or unhiding elements from a graph or simply invoking layout algorithms on a graph will have the potential side effect of changing that order.
With this comparison it is possible to establish a predefined order of edges within a graph to avoid non-deterministic layout behavior.
Signature Details
function(x: IEdge, y: IEdge) : number
Parameters
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
See Also
Gets a mapping from edges in the LayoutGraph to their new layout, after the results are in.
Remarks
Throws
- Exception({ name: 'InvalidOperationError' })
- Throws when the results are not yet available.
See Also
Gets or sets the size of the nodes that are inserted for the ports that are created for IEdges that are connected at other IEdges.
Remarks
3x3
.See Also
Gets the graph this instance is working on.
Remarks
Property Value
Gets the component this instance has been created for.
Remarks
Property Value
null
if this instance runs without a graph component.Gets or sets a value that controls whether edges at other edges will be hidden from the layout graph or included.
Gets a mapping from labels in the LayoutGraph to their new layout, after the results are in.
Remarks
Throws
- Exception({ name: 'InvalidOperationError' })
- Throws when the results are not yet available.
See Also
Gets a mapping from labels in the LayoutGraph to their new layout parameters, after the results are in.
Remarks
Throws
- Exception({ name: 'InvalidOperationError' })
- Throws when the results are not yet available.
See Also
Gets or sets a mapping that specifies how ILabels should be placed by the layout algorithm.
Remarks
This setting only affects layout algorithms which support label placement. Also, if EdgeLabelPreferredPlacements are already defined for a label, all values other than KEEP_PARAMETER are ignored for that label.
Default is PREFER_MODEL.
Examples
Maintain the current label positions as much as possible during layout:
const layoutDescriptor: LayoutDescriptor = {
name: 'HierarchicalLayout',
}
await new LayoutExecutorAsync({
messageHandler: webWorkerMessageHandler,
graphComponent: graphComponent,
layoutDescriptor: layoutDescriptor,
labelPlacementPolicies: LabelPlacementPolicy.PREFER_PARAMETER,
}).start()
Customize label placement individually for each label. In this example, the placement policy is determined by the type of the label's owner:
const layoutDescriptor: LayoutDescriptor = {
name: 'HierarchicalLayout',
}
await new LayoutExecutorAsync({
messageHandler: webWorkerMessageHandler,
graphComponent: graphComponent,
layoutDescriptor: layoutDescriptor,
labelPlacementPolicies: (label) =>
label.owner instanceof INode
? LabelPlacementPolicy.PREFER_MODEL
: LabelPlacementPolicy.PREFER_PARAMETER,
}).start()
See Also
Gets or sets the descriptor that will be sent to the worker.
Remarks
See Also
Gets or sets a comparison function that normalizes the order of the nodes for the layout calculation to ensure the same order for multiple layout invocations.
Remarks
Among other factors, the results produced by layout algorithms usually depend on the order of the nodes and edges within a graph. Unfortunately, useful operations such as hiding or unhiding elements from a graph or simply invoking layout algorithms on a graph will have the potential side effect of changing that order.
With this comparison it is possible to establish a predefined order of nodes within a graph to avoid non-deterministic layout behavior.
Signature Details
function(x: INode, y: INode) : number
Parameters
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
See Also
Gets a mapping from nodes in the LayoutGraph to their new layout, after the results are in.
Remarks
Throws
- Exception({ name: 'InvalidOperationError' })
- Throws when the results are not yet available.
See Also
Gets or sets the mapping from ports to a policy that specifies how port locations should be adjusted after a layout has been calculated.
Remarks
This can be useful if the port assignment calculated by the layout algorithm is insufficient.
Layout algorithms only consider rectangular nodes even though the actual shape of a node is, for example, circular. Hence, the ports are usually placed at the border of the nodes' bounds (except for some layout algorithms that produce straight-line edge routes and place the ports at the nodes' center).
Based on this setting the edges will be shortened or lengthened in a way that their sourcePorts and targetPorts will be placed on the node's outline.
The default is a constant ItemMapping<TItem,TValue> returning LENGTHEN for all ports.
Examples
Automatically lengthen or shorten edges at all ports if the port is not located on the owner's outline:
const layoutDescriptor: LayoutDescriptor = {
name: 'HierarchicalLayout',
}
await new LayoutExecutorAsync({
messageHandler: webWorkerMessageHandler,
graphComponent: graphComponent,
layoutDescriptor: layoutDescriptor,
portAdjustmentPolicies: PortAdjustmentPolicy.ALWAYS,
}).start()
Customize edge adjustments individually for each port. In this example, the policy is determined by the type of the port's owner:
const layoutDescriptor: LayoutDescriptor = {
name: 'HierarchicalLayout',
}
await new LayoutExecutorAsync({
messageHandler: webWorkerMessageHandler,
graphComponent: graphComponent,
layoutDescriptor: layoutDescriptor,
portAdjustmentPolicies: (port) =>
port.owner instanceof INode
? PortAdjustmentPolicy.SHORTEN
: PortAdjustmentPolicy.LENGTHEN,
}).start()
See Also
Gets a mapping from ports in the LayoutGraph to their new location parameters, after the results are in.
Remarks
Throws
- Exception({ name: 'InvalidOperationError' })
- Throws when the results are not yet available.
See Also
Gets or sets how ILabels at IPorts should be treated by the layout algorithm.
Remarks
Examples
Treat all port labels as edge labels during layout:
const layoutDescriptor: LayoutDescriptor = {
name: 'HierarchicalLayout',
}
await new LayoutExecutorAsync({
messageHandler: webWorkerMessageHandler,
graphComponent: graphComponent,
layoutDescriptor: layoutDescriptor,
portLabelPolicies: PortLabelPolicy.EDGE_LABEL,
}).start()
Customize the handling of port labels individually. In this example, the policy is determined by the type of the port's owner:
const layoutDescriptor: LayoutDescriptor = {
name: 'HierarchicalLayout',
}
await new LayoutExecutorAsync({
messageHandler: webWorkerMessageHandler,
graphComponent: graphComponent,
layoutDescriptor: layoutDescriptor,
portLabelPolicies: (label) =>
label.owner instanceof IPort && label.owner.owner instanceof INode
? PortLabelPolicy.NODE_LABEL
: PortLabelPolicy.EDGE_LABEL,
}).start()
See Also
Gets or sets a mapping that specifies how IPorts should be placed by the layout algorithm.
Remarks
This setting only affects layout algorithms which support PortCandidates. Also, if PortCandidates are already defined for an edge, they override the current port positions.
Default is PREFER_MODEL.
Examples
Maintain the current port locations as much as possible during layout:
const layoutDescriptor: LayoutDescriptor = {
name: 'HierarchicalLayout',
}
await new LayoutExecutorAsync({
messageHandler: webWorkerMessageHandler,
graphComponent: graphComponent,
layoutDescriptor: layoutDescriptor,
portPlacementPolicies: PortPlacementPolicy.KEEP_SIDE,
}).start()
Customize port locations individually for each port. In this example, the placement policy is determined by the type of the port's owner:
const layoutDescriptor: LayoutDescriptor = {
name: 'HierarchicalLayout',
}
await new LayoutExecutorAsync({
messageHandler: webWorkerMessageHandler,
graphComponent: graphComponent,
layoutDescriptor: layoutDescriptor,
portPlacementPolicies: (port) =>
port.owner instanceof INode
? PortPlacementPolicy.KEEP_PARAMETER
: PortPlacementPolicy.PREFER_MODEL,
}).start()
See Also
Gets a value indicating whether this instance is currently running.
Remarks
Property Value
Gets or sets a value indicating whether this instance waits for other instances to finish their operations before it executes.
Remarks
The default value is true
. In this case, this instance waits for other instances of LayoutExecutor, and LayoutExecutorAsync respectively, that work on the same instance of GraphComponent to finish their operation before it starts execution.
If set to false
, this instance ignores other potentially running instances, and doesn't try to stop them but rather executes immediately. Also it will not be stopped by other instances. This should only be used under special circumstances since it can result in race conditions if multiple animations or calculations are performed on the same graph instance.
Gets or sets the duration a layout may run before being stopped automatically.
Remarks
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the duration is negative
See Also
Gets the TableLayoutConfigurator that is used if configureTableLayout is enabled.
Gets or sets a value indicating whether the contentBounds property of the graphComponent should be updated upon completion.
Remarks
true
.Property Value
true
if the content bounds should be updated; false
otherwise.Methods
Cancels a currently running layout calculation or animation.
Remarks
If a layout calculation is still running, the results of the other LayoutExecutorAsyncWorker are discarded and not applied to the graph. If the layout calculation was already completed and an animation is running, it will be aborted immediately and the layout result will be applied and shown immediately.
The promise returned from start is resolved immediately, without waiting for pending layout results. Results returned from running workers are silently discarded when passed on to this instance. The workers are not terminated when this method was called.
To just skip the animation but let the calculation finish normally, the animationDuration can be set to zero at any time before the animation was started.
Returns
- ↪Promise<void>
- A
Promise
that will resolve once the layout calculation or animation is canceled.
Factory method that creates the IAnimation that will be used by this instance after the layout has been calculated.
Remarks
Returns
- ↪IAnimation
- The animation to use after the layout.
See Also
Callback factory method that creates the IRectangle for the given IPort that is used as a dummy to represent the port at the IEdge that owns port
.
Parameters
A map of options to pass to the method.
- port - IPort
- The port to create the layout for.
Returns
- ↪IRectangle
- An IRectangle that uses the port's location as the center of the node.
See Also
Factory method that creates the animation for the IGraph.
Remarks
Returns
- ↪IAnimation
- The animation instance.
See Also
Creates an animation that morphs the layout of all ITables in the graph.
Remarks
Returns
- ↪IAnimation
- The animation that morphs the layout of all ITables in the graph.
See Also
Create a new instance of TableLayoutConfigurator that is used if configureTableLayout is enabled.
Remarks
Returns
- ↪TableLayoutConfigurator
- A new instance of the TableLayoutConfigurator class.
Factory method that creates the animation for the viewport.
Remarks
Parameters
A map of options to pass to the method.
- targetBounds - Rect
- The target bounds of the animation.
Returns
- ↪IAnimation
- The animation instance.
See Also
Calculate the target bounds to be used for the contentBounds as well as the ViewportAnimation after the layout has finished.
Returns
- ↪Rect
- The desired content bounds and the bounds for a viewport animation.
Sets up partition grid information from tables in the graph.
Remarks
Returns
- ↪LayoutGridData<INode,IEdge,ILabel,ILabel>?
- A LayoutGridData<TNode,TEdge,TNodeLabel,TEdgeLabel> instance for all tables in the graph, or
null
if no LayoutGrid is necessary.
Writes the table layout information provided through tableLayoutConfigurator back to all tables.
Remarks
See Also
Triggers the asynchronous execution and returns a Promise
that resolves when the calculation is done.
Remarks
This will serialize the LayoutGraph, the layoutDescriptor, and the LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> and send that information via the callback function that was passed to the constructor at construction time to the remote worker
After the results have been returned, they will be parsed by this instance, the results will be applied to the graph, either in an animated fashion or directly.
Returns
- ↪Promise<void>
- The promise to track the progress of the execution.
Throws
- Exception({ name: 'Error' })
Static Methods
Convenience method for creating a default message handler for a web worker that can be passed to the LayoutExecutorAsync constructor.
Remarks
Parameters
A map of options to pass to the method.
- worker - Worker
- The web worker instance that the messages should be exchanged with.
Returns
- ↪function(object):Promise<object>
- A default message handler for the given web worker instance.
Signature Details
function(data: object) : Promise<object>
Implements message passing between two contexts.LayoutExecutorAsync uses this function to senddata
to the LayoutExecutorAsyncWorker. After the worker has performed its task, it will send back the results and the need to be returned (resolved via thePromise
) to the calling code. Implementations can expect the values to be JSON serializable and structurally cloneable . Otherwise, the contents of the data blob are considered an implementation detail and may change at any time between releases.Parameters
- data - object
- The data to send to the
method in the worker context.
Returns
- Promise<object>
- A
Promise
that will resolve to the data received from the worker context.