summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorVickodev <harvic3@gmail.com>2019-06-25 17:08:02 -0500
committerMichaƫl Zasso <targos@protonmail.com>2019-07-20 11:29:58 +0200
commitca83b2736e2b7c0f8fe1d4d0639bd00d7fb1ea54 (patch)
tree3d3c30a34bb4aabf2a318326b75db8f6adc0fa54 /doc
parent44acec53862047b2b1e92d599525fd7b7986f73f (diff)
downloadandroid-node-v8-ca83b2736e2b7c0f8fe1d4d0639bd00d7fb1ea54.tar.gz
android-node-v8-ca83b2736e2b7c0f8fe1d4d0639bd00d7fb1ea54.tar.bz2
android-node-v8-ca83b2736e2b7c0f8fe1d4d0639bd00d7fb1ea54.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')
-rw-r--r--doc/api/process.md17
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