如何为程序退出添加回调?
在nodejs中的实现:
process.on('exit', function (){
console.log('Goodbye!');
});
Run Code Online (Sandbox Code Playgroud)
您可以使用unload
// window. also work outside workers
globalThis.addEventListener("unload", () => {
console.log('goodbye!');
});
setTimeout(() => console.log('before goodbye'), 1000);
Run Code Online (Sandbox Code Playgroud)
调用时也会触发Deno.exit()。您可以在此处查看有关程序生命周期的更多信息。
| 归档时间: |
|
| 查看次数: |
1221 次 |
| 最近记录: |