Skip to content

MiddlewareHelpers

Helper functions for checking what changed during middleware execution. These helpers track all cumulative changes from the initial state update and all previous middlewares.

anyEdgesAdded: () => boolean

Checks if any edges were added.

boolean

true if at least one edge was added by the initial state update or any previous middleware


anyEdgesRemoved: () => boolean

Checks if any edges were removed.

boolean

true if at least one edge was removed by the initial state update or any previous middleware


anyNodesAdded: () => boolean

Checks if any nodes were added.

boolean

true if at least one node was added by the initial state update or any previous middleware


anyNodesRemoved: () => boolean

Checks if any nodes were removed.

boolean

true if at least one node was removed by the initial state update or any previous middleware


checkIfAnyEdgePropsChanged: (props) => boolean

Checks if any edge has one or more of the specified properties changed.

string[]

Array of property names to check (e.g., [‘sourcePosition’, ‘targetPosition’])

boolean

true if any edge has any of these properties modified by the initial state update or any previous middleware


checkIfAnyNodePropsChanged: (props) => boolean

Checks if any node has one or more of the specified properties changed.

string[]

Array of property names to check (e.g., [‘position’, ‘size’])

boolean

true if any node has any of these properties modified by the initial state update or any previous middleware


checkIfEdgeAdded: (id) => boolean

Checks if a specific edge was added.

string

The edge ID to check

boolean

true if the edge was added by the initial state update or any previous middleware


checkIfEdgeChanged: (id) => boolean

Checks if a specific edge has been modified.

string

The edge ID to check

boolean

true if the edge was modified (any property changed) by the initial state update or any previous middleware


checkIfEdgeRemoved: (id) => boolean

Checks if a specific edge was removed.

string

The edge ID to check

boolean

true if the edge was removed by the initial state update or any previous middleware


checkIfNodeAdded: (id) => boolean

Checks if a specific node was added.

string

The node ID to check

boolean

true if the node was added by the initial state update or any previous middleware


checkIfNodeChanged: (id) => boolean

Checks if a specific node has been modified.

string

The node ID to check

boolean

true if the node was modified (any property changed) by the initial state update or any previous middleware


checkIfNodeRemoved: (id) => boolean

Checks if a specific node was removed.

string

The node ID to check

boolean

true if the node was removed by the initial state update or any previous middleware


getAddedEdges: () => Edge<object>[]

Gets all edges that were added.

Edge<object>[]

Array of edge instances that were added by the initial state update or any previous middleware


getAddedNodes: () => Node[]

Gets all nodes that were added.

Node[]

Array of node instances that were added by the initial state update or any previous middleware


getAffectedEdgeIds: (props) => string[]

Gets all edge IDs that have one or more of the specified properties changed.

string[]

Array of property names to check (e.g., [‘sourcePosition’, ‘targetPosition’])

string[]

Array of edge IDs that have any of these properties modified by the initial state update or any previous middleware


getAffectedNodeIds: (props) => string[]

Gets all node IDs that have one or more of the specified properties changed.

string[]

Array of property names to check (e.g., [‘position’, ‘size’])

string[]

Array of node IDs that have any of these properties modified by the initial state update or any previous middleware


getRemovedEdges: () => Edge<object>[]

Gets all edges that were removed. Uses initialEdgesMap to access the removed instances.

Edge<object>[]

Array of edge instances that were removed by the initial state update or any previous middleware


getRemovedNodes: () => Node[]

Gets all nodes that were removed. Uses initialNodesMap to access the removed instances.

Node[]

Array of node instances that were removed by the initial state update or any previous middleware