What is the event for model change in DMN modeler

Would like to know whenever the model (not the canvas or view, but the underlying XML) changes in the DMN model editor (either the DRD or the tables). What is the way to achieve it?

The events canvas.viewbox.changed and views.changed are not getting raised when a new shape is added to the DRD, or decision table values are changed.

The requirement is to, say, auto-save the changed XML. Could not find any relevant event for this. Appreciate any inputs.

I think the easiest way would be to listen for the elements.changed event.

const activeEditor = dmnModeler.getActiveViewer();

const eventBus = activeEditor.get('eventBus');

eventBus.on('elements.changed', function(event) {
   console.log(event.elements);
});

You can use it in any editor, see this CodeSandbox how to use via an additional module.

You could then use the saveXML of the dmn editor to export the current XML state.

1 Like