Delete a node with links

I know if there are links associated with a node, when deleting a node, the links will be removed as well.

I can see events from, the links gets deleted first and then the node itself.

However, I realize the node itself deleted prior to the “linkDataArray” in addModelChangedListener. In this case, though I have oldValue, I can not use e.model.findNodeDataForKey( to get NodeData.

if (e.modelChange === “linkDataArray”) { // remove link
let fromNode = e.model.findNodeDataForKey(e.oldValue.from); // it will be null if deleting source node
let toNode = e.model.findNodeDataForKey(; // it will be null if deleting target node

Then, how can I get the node being deleted in addModelChangedListener? if (e.modelChange === “nodeDataArray”) is hit after if (e.modelChange === “linkDataArray”). But the node itself gets deleted already even before if (e.modelChange === “linkDataArray”).


Yes, if you want to detect that a node has been deleted in the model, you need to check for e.change === ChangedEvent.Remove && e.modelChange === "nodeDataArray".

After all, it might be that a link is being deleted by itself, or in conjunction with other links, but no nodes. Or it might be that both nodes that are connected by a link are being deleted.

Perhaps you want to look for e.change === ChangedEvent.Transaction && e.propertyName === "CommittedTransaction" and then scan the Transaction.changes list for all of the nodes and all of the links that were deleted.