botbook/node_modules/when-exit
Rodrigo Rodriguez 6ae15fe3e5 Updated.
2024-09-04 13:13:15 -03:00
..
dist Updated. 2024-09-04 13:13:15 -03:00
src Updated. 2024-09-04 13:13:15 -03:00
test Updated. 2024-09-04 13:13:15 -03:00
.editorconfig Updated. 2024-09-04 13:13:15 -03:00
license Updated. 2024-09-04 13:13:15 -03:00
package.json Updated. 2024-09-04 13:13:15 -03:00
readme.md Updated. 2024-09-04 13:13:15 -03:00
tsconfig.json Updated. 2024-09-04 13:13:15 -03:00

WhenExit

Execute a function right before the process, or the browser's tab, is about to exit.

Install

npm install --save when-exit

Usage

import whenExit from 'when-exit';

onExit ( () => {
  console.log ( 'Callback 1' );
});

onExit ( () => {
  console.log ( 'Callback 2' );
});

const disposer = onExit ( () => {
  console.log ( 'Callback 3' );
});

disposer ();

process.exit (); // Callback 1 and 2 are called before exiting

License

MIT © Fabio Spampinato