Executes an algorithm or ILayoutAlgorithm on a graph in a separate execution context.
Remarks
This class implements the "worker" part for the LayoutExecutorAsync. It will serve requests started by the layout executor in the main thread, perform the actual calculations and send back the results. 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 deserialize all the information received from the LayoutExecutorAsync, let the callback passed to the constructor perform the actual calculations, and send back the results. Instances of this class often execute in a Web Worker, but it could also be running on a different machine or a server, separate from the browser.
The actual transmission of the serialized data from and to the other context is not part of this implementation. Rather the reception of the data needs to be implemented by users of this class. The data will then be passed to the process method, for deserialization.
Related Reading in the Developer's Guide
Type Details
- yfiles module
- view-layout-bridge
- yfiles-umd modules
- view-layout-bridge
- Legacy UMD name
- yfiles.layout.LayoutExecutorAsyncWorker
See Also
Constructors
Creates a new instance of a layout service worker.
Remarks
handler
function. Upon each call to process, this instance will deserialize the data, construct the graph, attach the data to the graph elements and pass the graph and LayoutDescriptor
to the callback function. The function will perform the work on the graph and may optionally use the descriptor
to create and configure the corresponding algorithms. Once the function returns or resolves the Promise
in case of asynchronous execution, the data will again be serialized and returned to the caller of process, who is responsible for sending back the opaque serialized blob back to the main context. The contents of the data blob are considered an implementation detail and may change at any time between releases.Parameters
A map of options to pass to the method.
- handler - function(LayoutGraph, Object):Promise<Object>
- The handler that will perform the actual calculations
Signature Details
function(graph: LayoutGraph, descriptor: Object) : Promise<Object>
Implements the actual work in the context of a LayoutExecutorAsync.LayoutExecutorAsyncWorker uses this function to actually trigger the the execution of the algorithm. The function can use thedescriptor
to create and configure the algorithm and will then apply it to thegraph
. It's up to the implementation what kind of algorithm runs. The results will need to manifest on the graph and it's IDataProviders. Once the method returns or resolves the returned optionalPromise
the graph will be serialized again and returned to the caller of the process method for transmission back to the calling worker message handler.Parameters
- graph - LayoutGraph
- The graph to perform the calculations on. If you need a custom graph implementation, consider overwriting
. - descriptor - Object
- The descriptor that was set on the
and send to this context.
Returns
Methods
Factory method that creates the graph that will be passed to the worker handler
Remarks
Returns
- ↪LayoutGraph
- The layout graph to use for the ongoing service request
Called by client code for each data blob received from the main thread's layout request.
Remarks
Promise
resolves, the value needs to be send back to the calling thread for further processing by the worker message handler that sent the request.Parameters
A map of options to pass to the method.
- data - Object
- The data that was given to the worker message handler. The contents of the data are considered an implementation detail and may change at any time between releases.
Returns
- ↪Promise<Object>
- The Promise that will resolve to the data that needs to be sent back to the calling worker message handler.
See Also
Constants
A data provider key that can be used to retrieve information about unconnectedports of the original YNode or Edge.