Programmatically adding a new node after another node is dragged

I have a diagram listener, “ExternalObjectsDropped”, that is called when I drag a node into my diagram from a Palette next to it…

In response to that newly dragged node, I’d like to create other new nodes using the model.addNodeDataCollection and model.addLinkDataCollection. But I’m performing this logic with my ExternalObjectsDropped event handler, and I feel that this is the wrong place. Also I’m getting an error that I shouldn’t modify my model’s data while a “transaction” is in progress.

What is the proper way to programmatically add nodes based on other nodes being dragged into my diagram? Would I have to do some kind of callback called from the event handler?

Sorry for the post and quick followup, I think I found the solution after a little bit more digging.

Instead of addNodeDataCollection & addLinkDataCollection, I’m using addNodeData and addLinkData. That seems to do the trick.

If there is an even better, or more proper way, please let me know. but for now this has unblocked me.

(fyi, a related topic: Programmatically deleting a node after its dragged )