Hey,
I know that the walkthrough might raise more questions than it answers.
Under the hood bpmn-js which is built on top of diagram-js uses didi for dependency injection. So things like myModule: [ 'type', MyModuleContructor ]
are handled by didi. The __init__
and __depends__
properties you saw are something that is not part of didi but is handled by diagram-js when the instance is created. You can see it in action here.
The __init__
property specifies any modules you want to instantiate. This makes sure that even if no other module asks for this component this component will be instantiated and can hook into the applications life cycle. Most of the modules in bpmn-js are instantiated like that and usually you’d want to instantiate your module, too.
The __depends__
property specifies which modules a module depends on. Any modules that are specified as dependencies will be made available so that they can be injected into the module that depends on them.
Unfortunately there is no list of all modules you can inject into your module.
To answer your last question:
Yes, you can access the XML of your diagram by either taking the XML you imported into bpmn-js in the first place or by injecting the instance of bpmn-js itself which is available like any other module:
function MyModule(bpmnjs) {
bpmnjs.saveXML(function(err, xml) {
// there is your XML
});
}
MyModule.$inject = [ 'bpmnjs' ];
Can you give more context about what you want to do with the XML? If you only want to get the ID of the process you can do that easily by getting the root element from the canvas, which is another module you can inject:
function MyModule(canvas) {
var root = canvas.getRootElement();
var businessObject = root.businessObject;
var id = businessObject.id; // there is your ID
}
MyModule.$inject = [ 'canvas' ];
I hope I could help you.