Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue instance manually destroy #697

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/drawflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export default class Drawflow {
// Mobile
this.evCache = new Array();
this.prevDiff = -1;

// Vue
this.vueInstances = {};
}

start () {
Expand Down Expand Up @@ -1242,6 +1245,7 @@ export default class Drawflow {
...this.noderegister[html].options
}).$mount()
//
this.vueInstances[newNodeId] = wrapper;
content.appendChild(wrapper.$el);
}
}
Expand Down Expand Up @@ -1724,6 +1728,10 @@ export default class Drawflow {
this.container.querySelector(`#${id}`).remove();
}
delete this.drawflow.drawflow[moduleName].data[id.slice(5)];
if(this.vueInstances[id.slice(5)]) {
this.vueInstances[id.slice(5)].$destroy();
delete this.vueInstances[id.slice(5)];
}
this.dispatch('nodeRemoved', id.slice(5));
}

Expand Down Expand Up @@ -1877,6 +1885,9 @@ export default class Drawflow {
clear () {
this.precanvas.innerHTML = "";
this.drawflow = { "drawflow": { "Home": { "data": {} }}};

Object.keys(this.vueInstances).forEach(key => this.vueInstances[key].$destroy());
this.vueInstances = {};
}
export () {
const dataExport = JSON.parse(JSON.stringify(this.drawflow));
Expand Down