Closed kevn-xyz closed 7 years ago
It is synchronous, due to be able to cancel the close action! Why do you think it is async? Give me an example!
if (openDialoags.files.indexOf(currentFile) != -1) { //Removes old dialog if relinting the same file
var objIndex = openDialogs.files.indexOf(currentFile);
openDialogs.dialogObjs[objIndex].close();
openDialogs.dialogObjs[objIndex].hide();
}
...
alert("step") // as long as this is here everything runs fine.
...
dockable = {
name: "ESLint",
docking: globalCCSettings.so.dialogPos,
onbeforeclose: (function(oDindex) {
return function() {
openDialogs.dialogObjs.splice(oDindex, 1);
openDialogs.files.splice(oDindex, 1);
return true;
};
})(openDialogs.files.length)
};
...
var dialCfg = new Dialog.Grid({});
...
openDialogs.dialogObjs.push(new Dialog(dialCfg));
openDialogs.files.push(currentFile);
Without the alert("step")
the new dockable seems to be created before the old dockables onbeforeclose has run and cleaned itself from the openDialogs arrays (ie. its oDindex is 1 higher than it should be).
Im assuming (openDialoags.files.indexOf(currentFile) != 1) == true
You are right, the method dialog.close() is asynchronous. I don't know any more, what was the descision to do it so.
For the moment you can move code after .close()
into onclose
handler
I could have but then I would have had to added quite a few flags and if statements. I just reworked the code using IDs for the array elements. Thanks for your time
Does onbeforeclose get triggered asynchronously from IDialog.close()? If I insert an alert after close() then everything runs fine. Is there anyway I can force it to be synchronous if it is in fact async?