Handle commandstack events by type


Hi all,
Thanks for this great lib. I managed to integrate it in my web site and it works good. However, I configure it that now I add extra informations to tasks like who’s doing it.etc. The problem is when I delete a task I delete also those infos, but if I make an undo the shape gets back but the data is lost.
I tried
bpmnModeler.on('commandStack.changed', function () { // user modeled something or // performed a undo/redo operation console.log("cs change.."); });
But this not giving me the type of the change.
Any one has an idea how to make this ?


The way the command stack works is that it encapsulates all information needed to perform a command. Therefore the command can later be reverted and re-executed. You have to implement a command handler that knows how to execute and revert adding your information. Right now you’re just adding it to the element without letting the command stack know about it. So if you’re deleting the element and then undo the information is lost. You can take the UpdatePropertiesHandler as an example. It takes care of changing the properties of an element in a way that it can be reverted.


Thanks for your replay.
I will give it a try.