Skip to content

FlowStateUpdate

Describes a set of changes to apply to the diagram state. Middlewares can modify state by passing a FlowStateUpdate to the next() function.

const middleware: Middleware = {
name: 'auto-arranger',
execute: (context, next) => {
// Apply state changes
next({
nodesToUpdate: [
{ id: 'node1', position: { x: 100, y: 200 } },
{ id: 'node2', position: { x: 300, y: 200 } }
],
metadataUpdate: {
viewport: { x: 0, y: 0, zoom: 1 }
}
});
}
};

optional edgesToAdd: Edge<object>[]

Edges to add to the diagram


optional edgesToRemove: string[]

IDs of edges to remove from the diagram


optional edgesToUpdate: Partial<Edge<object>> & object[]

Partial edge updates (only changed properties need to be specified)


optional metadataUpdate: Partial<Metadata<object>>

Partial metadata update (viewport, selection, etc.)


optional nodesToAdd: Node[]

Nodes to add to the diagram


optional nodesToRemove: string[]

IDs of nodes to remove from the diagram


optional nodesToUpdate: Partial<Node> & object[]

Partial node updates (only changed properties need to be specified)