How do you add a callback for the program exiting?
Implementation in nodejs:
process.on('exit', function (){
console.log('Goodbye!');
});
How do you add a callback for the program exiting?
Implementation in nodejs:
process.on('exit', function (){
console.log('Goodbye!');
});
You can use unload
window.addEventListener("unload", () => {
console.log('goodbye!');
});
setTimeout(() => console.log('before goodbye'), 1000);
You can check more about Program Lifecycle here.
Unfortunately it won't be called if Deno.exit() is called. There's an open issue regarding this, and hopefully, it will be possible soon.