feat(Viewer): make importXML callback optional

People could be hooking up with import via events, too.
This commit is contained in:
Nico Rehwaldt 2016-03-17 10:42:14 +01:00
parent 46d8abdd70
commit 37eca38dac
3 changed files with 22 additions and 2 deletions

View File

@ -117,7 +117,7 @@ module.exports = Modeler;
/**
* Create a new diagram to start modeling.
*
* @param {Function} done
* @param {Function} [done]
*/
Modeler.prototype.createDiagram = function(done) {
return this.importXML(initialDiagram, done);

View File

@ -144,10 +144,13 @@ module.exports = Viewer;
* You can use these events to hook into the life-cycle.
*
* @param {String} xml the BPMN 2.0 xml
* @param {Function} done invoked with (err, warnings=[])
* @param {Function} [done] invoked with (err, warnings=[])
*/
Viewer.prototype.importXML = function(xml, done) {
// done is optional
done = done || function() {};
var self = this;
// hook in pre-parse listeners +

View File

@ -769,6 +769,23 @@ describe('Viewer', function() {
});
});
it('should work without callback', function(done) {
// given
var viewer = new Viewer({ container: container });
var xml = require('../fixtures/bpmn/simple.bpmn');
// when
viewer.importXML(xml);
// then
viewer.on('import.done', function(event) {
done();
});
});
});