Skip to main content

Callbacks

All callbacks receive two arguments: info with the information about event occured, and rootStore which gives you access to entire diagram state.

To start using any callbacks define them in settings:

const YourDiagram = () => (
<Diagram initState={...} settings={{
callbacks: {
onNodesAddResult: (info, store) => {
if (info.addedNodes.length > 0) {
console.log('Added nodes:',info.addedNodes.map((n) => n.export()));
}
}
}
}} />
);
tip

Here you can find example of callbacks usage.

onNodesAddResult

Is called whenever addNodes, addNode or import are called regardless of the fact if any nodes were actually added.

Information type: OnNodesAddResult

onNodesRemoveResult

Is called whenever removeNode, or removeNodes are called regardless of the fact if any nodes were actually removed.

Information type: OnNodesRemoveResult

onNodePositionChanged

Information type: OnNodePositionChanged

onNodeLabelChanged

Information type: onNodeLabelChanged

onNodeTypeChanged

caution

If type is changed to undefined the COMPONENT_DEFAULT_TYPE will be used but in callback newValue will be undefined.

Information type: onNodeTypeChanged

onNodeDataChanged

Information type: OnNodeDataChanged

onNodeIsSelectionEnabledChanged

Information type: OnNodeIsSelectionEnabledChanged

onNodeIsDragEnabledChanged

Information type: OnNodeIsDragEnabledChanged

onDragStarted

Information type: OnDragStarted

onDrag

Information type: OnDrag

onDragEnded

Information type: OnDragEnded

onImportedStateRendered

Is called whenever imported nodes and links are rendered. Callback does not provide any additional information.

onLinkValidation

Is called whenever the diagram is trying to validate if it is possible to connect source and target ports. This callback should return boolean where true means connecting is possible.

See example here.

Information type: OnLinkValidation

onLinksAddResult

Is called whenever addLinks, addLink or import are called regardless of the fact if any links were actually added.

Information type: OnLinksAddResult

onLinksRemoveResult

Is called whenever removeLink, or removeLinks are called regardless of the fact if any links were actually removed.

Information type: OnLinksRemoveResult

onLinkingStarted

Information type: OnLinkingStarted

onLinkingEnded

Information type: OnLinkingEnded