How to force a refresh on the diagram?

I need to make a refresh in the diagram in order to get the last changes after adding an extendedElement and export to a bpmn file.

If I don’t do that, the extendedElements would not be exported.

Is there a function to do it ?

Thank you

You have to dispatch model updates via our commandStack in order to make them undoable and appear on the diagram.

Have a look at this post or our FAQ entry that summarizes the issue.

If I add an extension element with this function:

    saveExtensionElements(moddle, sequenceFlow, property, object) {
      sequenceFlow.extensionElements = moddle.create('bpmn:ExtensionElements');
      let formProperties = moddle.create(property, object);
      sequenceFlow.extensionElements.get('values').push(formProperties);
    }

```

Then I need to refresh the diagram in order to export it, but if I fire the "commandStack.changed" event It can be exported successfully but I can't REDO it: 

```
        function refreshDiagram(viewer) {
          let eventBus = viewer.get('eventBus');
          eventBus.fire('commandStack.changed', {
            element: scope.currentComponent
          });
        };
```

As part of the bpmn-js-properties-panel we were implementing a set of custom handlers that do exactly the stuff you need.

Emitting the event will redraw the diagram only. As mentioned you’d need to hook up with our editing history to get redo/undo working.

For a general overview (redoable vs. not redoable), check out the bpmn-properties bpmn-js example.

I’ll take a look on the properties panel you’ve implemented.

Thank you very much for your help.