Overriding insertLink method of linkingTool

Hello,

I would like to override the method that creates the actual link following a successful drag and connection.
I am using Redux and I want push the link data to my store first, then let the Redux store push GoJS model updates.

By overriding the insertLink method of the linking tool i was able to prevent the nodes from being added to the model. However, I still need to capture ‘keys’ from both nodes and the ‘portID’ from both ports. I am not seeing an api that will let me access the portID and Key properties which I would need to programmatically create the link later.

var linkTool = diagram.toolManager.linkingTool
linkTool.insertLink = function(fromNode, fromPort, toNode, toPort) {
	 getStore().dispatch({
			type:"addLink", 
			data:{
				from:"",//here is where I need to access the fromNode key
				to:"",//here is where I need to access the toNode key
				fromPort:"",//here is where I need to access the fromPort id
				toPort:"",//here is where I need to access the toPort id
			}	
		})
	return null;
}

Does anyone have an idea where I can find this information?

Get them from the Node and GraphObject port arguments for each end of the Link: Node.data.key and GraphObject.portId

Thanks Walter,

That worked.

A post was split to a new topic: No relinking event when dragging a link?