Inheritence in goJs node and link templates


We have a situation where we need multiple types of templates for different nodes.
But these templates can share a similar behavior.

Is it possible to define a base template and can we inherit this template into other templates and override some of the behavior?

Thanks in advance.

Sure. Take a look at how the Data Flow sample is implemented.

Or have separate templates that call the same function to result in the same property settings and GraphObjects, such as in the FlowChart sample. – see the nodeStyle, makePort, and textStyle functions.

But note that it is not possible to actually share references to the same GraphObject in multiple templates. Each template must have its own copy of GraphObjects in its visual tree. That’s why all those functions called for multiple templates construct and return their own objects.