diff options
author | Vickodev <harvic3@gmail.com> | 2019-06-25 17:08:02 -0500 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-07-17 22:01:22 -0700 |
commit | ed24b8f10ac34a1191c0d884b3074f15f0ba6e70 (patch) | |
tree | 76bc2e1cfe1e82f361bc29b42476d07df8f4cc3a /doc/api/process.md | |
parent | 57ed7c33b1e142c8df9b57f0907055774e8b46c4 (diff) | |
download | android-node-v8-ed24b8f10ac34a1191c0d884b3074f15f0ba6e70.tar.gz android-node-v8-ed24b8f10ac34a1191c0d884b3074f15f0ba6e70.tar.bz2 android-node-v8-ed24b8f10ac34a1191c0d884b3074f15f0ba6e70.zip |
doc: add example for beforeExit event
PR-URL: https://github.com/nodejs/node/pull/28430
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'doc/api/process.md')
-rw-r--r-- | doc/api/process.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/api/process.md b/doc/api/process.md index 826877381c..aa7477d3bc 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -36,6 +36,23 @@ termination, such as calling [`process.exit()`][] or uncaught exceptions. The `'beforeExit'` should *not* be used as an alternative to the `'exit'` event unless the intention is to schedule additional work. +```js +process.on('beforeExit', (code) => { + console.log('Process beforeExit event with code: ', code); +}); + +process.on('exit', (code) => { + console.log('Process exit event with code: ', code); +}); + +console.log('This message is displayed first.'); + +// Prints: +// This message is displayed first. +// Process beforeExit event with code: 0 +// Process exit event with code: 0 +``` + ### Event: 'disconnect' <!-- YAML added: v0.7.7 |