Deno:退出回调
Deno: Callback on exit
如何添加程序退出的回调?
在 nodejs 中的实现:
process.on('exit', function (){
console.log('Goodbye!');
});
您可以使用unload
window.addEventListener("unload", () => {
console.log('goodbye!');
});
setTimeout(() => console.log('before goodbye'), 1000);
您可以查看有关 Program Lifecycle here 的更多信息。
不幸的是,如果 Deno.exit()
被调用,它不会被调用。有一个关于此的 open issue,希望它很快就会成为可能。
如何添加程序退出的回调?
在 nodejs 中的实现:
process.on('exit', function (){
console.log('Goodbye!');
});
您可以使用unload
window.addEventListener("unload", () => {
console.log('goodbye!');
});
setTimeout(() => console.log('before goodbye'), 1000);
您可以查看有关 Program Lifecycle here 的更多信息。
不幸的是,如果 Deno.exit()
被调用,它不会被调用。有一个关于此的 open issue,希望它很快就会成为可能。