feat(Viewer): make importXML callback optional
People could be hooking up with import via events, too.
This commit is contained in:
parent
46d8abdd70
commit
37eca38dac
|
@ -117,7 +117,7 @@ module.exports = Modeler;
|
||||||
/**
|
/**
|
||||||
* Create a new diagram to start modeling.
|
* Create a new diagram to start modeling.
|
||||||
*
|
*
|
||||||
* @param {Function} done
|
* @param {Function} [done]
|
||||||
*/
|
*/
|
||||||
Modeler.prototype.createDiagram = function(done) {
|
Modeler.prototype.createDiagram = function(done) {
|
||||||
return this.importXML(initialDiagram, done);
|
return this.importXML(initialDiagram, done);
|
||||||
|
|
|
@ -144,10 +144,13 @@ module.exports = Viewer;
|
||||||
* You can use these events to hook into the life-cycle.
|
* You can use these events to hook into the life-cycle.
|
||||||
*
|
*
|
||||||
* @param {String} xml the BPMN 2.0 xml
|
* @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) {
|
Viewer.prototype.importXML = function(xml, done) {
|
||||||
|
|
||||||
|
// done is optional
|
||||||
|
done = done || function() {};
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
// hook in pre-parse listeners +
|
// hook in pre-parse listeners +
|
||||||
|
|
|
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue