chore: separate kill subprocess and dispose functions

This commit is contained in:
Louis 2023-10-03 16:11:13 +07:00 committed by Louis
parent fd512f2cee
commit d0e484a663
2 changed files with 7 additions and 1 deletions

View File

@ -13,7 +13,7 @@ const dispose = async () =>
new Promise(async (resolve) => {
if (window.electronAPI) {
window.electronAPI
.invokePluginFunc(MODULE_PATH, "killSubprocess")
.invokePluginFunc(MODULE_PATH, "dispose")
.then((res) => resolve(res));
}
});

View File

@ -72,6 +72,11 @@ async function initModel(product) {
}
function dispose() {
killSubprocess();
// clean other registered resources here
}
function killSubprocess() {
if (subprocess) {
subprocess.kill();
subprocess = null;
@ -83,5 +88,6 @@ function dispose() {
module.exports = {
initModel,
killSubprocess,
dispose,
};