Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
602 B
Text
41 lines
602 B
Text
# WhenExit
|
|
|
|
Execute a function right before the process, or the browser's tab, is about to exit.
|
|
|
|
## Install
|
|
|
|
```sh
|
|
npm install when-exit
|
|
```
|
|
|
|
## Usage
|
|
|
|
```ts
|
|
import whenExit from 'when-exit';
|
|
|
|
// Registering multiple callbacks
|
|
|
|
onExit ( () => {
|
|
console.log ( 'Callback 1' );
|
|
});
|
|
|
|
onExit ( () => {
|
|
console.log ( 'Callback 2' );
|
|
});
|
|
|
|
// Registering and disposing a callback
|
|
|
|
const disposer = onExit ( () => {
|
|
console.log ( 'Callback 3' );
|
|
});
|
|
|
|
disposer ();
|
|
|
|
// Triggering the process to exit
|
|
|
|
process.exit (); // Callback 1 and 2 are called before exiting
|
|
```
|
|
|
|
## License
|
|
|
|
MIT © Fabio Spampinato
|