diff options
author | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2017-02-13 04:49:35 +0200 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2017-02-20 13:11:11 -0800 |
commit | 52b253677a96021739d4c31ab4e3a01c3464e6db (patch) | |
tree | e29b83c574a9e6d015f2888040c09ebb38b0de10 /doc/api/domain.md | |
parent | dfa8abe1b500b86ffb3951736c209e57d83ed3ed (diff) | |
download | android-node-v8-52b253677a96021739d4c31ab4e3a01c3464e6db.tar.gz android-node-v8-52b253677a96021739d4c31ab4e3a01c3464e6db.tar.bz2 android-node-v8-52b253677a96021739d4c31ab4e3a01c3464e6db.zip |
doc: fix sorting in API references
PR-URL: https://github.com/nodejs/node/pull/11331
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Diffstat (limited to 'doc/api/domain.md')
-rw-r--r-- | doc/api/domain.md | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/doc/api/domain.md b/doc/api/domain.md index 1cc25e0cf8..00cb149bbd 100644 --- a/doc/api/domain.md +++ b/doc/api/domain.md @@ -269,42 +269,6 @@ uncaught exceptions to the active Domain object. Domain is a child class of [`EventEmitter`][]. To handle the errors that it catches, listen to its `'error'` event. -### domain.run(fn[, ...args]) - -* `fn` {Function} -* `...args` {any} - -Run the supplied function in the context of the domain, implicitly -binding all event emitters, timers, and lowlevel requests that are -created in that context. Optionally, arguments can be passed to -the function. - -This is the most basic way to use a domain. - -Example: - -```js -const domain = require('domain'); -const fs = require('fs'); -const d = domain.create(); -d.on('error', (er) => { - console.error('Caught error!', er); -}); -d.run(() => { - process.nextTick(() => { - setTimeout(() => { // simulating some various async stuff - fs.open('non-existent file', 'r', (er, fd) => { - if (er) throw er; - // proceed... - }); - }, 100); - }); -}); -``` - -In this example, the `d.on('error')` handler will be triggered, rather -than crashing the program. - ### domain.members * {Array} @@ -328,13 +292,6 @@ the domain 'error' handler. If the Timer or EventEmitter was already bound to a domain, it is removed from that one, and bound to this one instead. -### domain.remove(emitter) - -* `emitter` {EventEmitter|Timer} emitter or timer to be removed from the domain - -The opposite of [`domain.add(emitter)`][]. Removes domain handling from the -specified emitter. - ### domain.bind(callback) * `callback` {Function} The callback function @@ -363,6 +320,49 @@ d.on('error', (er) => { }); ``` +### domain.dispose() + +> Stability: 0 - Deprecated. Please recover from failed IO actions +> explicitly via error event handlers set on the domain. + +Once `dispose` has been called, the domain will no longer be used by callbacks +bound into the domain via `run`, `bind`, or `intercept`, and a `'dispose'` event +is emitted. + +### domain.enter() + +The `enter` method is plumbing used by the `run`, `bind`, and `intercept` +methods to set the active domain. It sets `domain.active` and `process.domain` +to the domain, and implicitly pushes the domain onto the domain stack managed +by the domain module (see [`domain.exit()`][] for details on the domain stack). The +call to `enter` delimits the beginning of a chain of asynchronous calls and I/O +operations bound to a domain. + +Calling `enter` changes only the active domain, and does not alter the domain +itself. `enter` and `exit` can be called an arbitrary number of times on a +single domain. + +If the domain on which `enter` is called has been disposed, `enter` will return +without setting the domain. + +### domain.exit() + +The `exit` method exits the current domain, popping it off the domain stack. +Any time execution is going to switch to the context of a different chain of +asynchronous calls, it's important to ensure that the current domain is exited. +The call to `exit` delimits either the end of or an interruption to the chain +of asynchronous calls and I/O operations bound to a domain. + +If there are multiple, nested domains bound to the current execution context, +`exit` will exit any domains nested within this domain. + +Calling `exit` changes only the active domain, and does not alter the domain +itself. `enter` and `exit` can be called an arbitrary number of times on a +single domain. + +If the domain on which `exit` is called has been disposed, `exit` will return +without exiting the domain. + ### domain.intercept(callback) * `callback` {Function} The callback function @@ -401,48 +401,48 @@ d.on('error', (er) => { }); ``` -### domain.enter() - -The `enter` method is plumbing used by the `run`, `bind`, and `intercept` -methods to set the active domain. It sets `domain.active` and `process.domain` -to the domain, and implicitly pushes the domain onto the domain stack managed -by the domain module (see [`domain.exit()`][] for details on the domain stack). The -call to `enter` delimits the beginning of a chain of asynchronous calls and I/O -operations bound to a domain. - -Calling `enter` changes only the active domain, and does not alter the domain -itself. `enter` and `exit` can be called an arbitrary number of times on a -single domain. +### domain.remove(emitter) -If the domain on which `enter` is called has been disposed, `enter` will return -without setting the domain. +* `emitter` {EventEmitter|Timer} emitter or timer to be removed from the domain -### domain.exit() +The opposite of [`domain.add(emitter)`][]. Removes domain handling from the +specified emitter. -The `exit` method exits the current domain, popping it off the domain stack. -Any time execution is going to switch to the context of a different chain of -asynchronous calls, it's important to ensure that the current domain is exited. -The call to `exit` delimits either the end of or an interruption to the chain -of asynchronous calls and I/O operations bound to a domain. +### domain.run(fn[, ...args]) -If there are multiple, nested domains bound to the current execution context, -`exit` will exit any domains nested within this domain. +* `fn` {Function} +* `...args` {any} -Calling `exit` changes only the active domain, and does not alter the domain -itself. `enter` and `exit` can be called an arbitrary number of times on a -single domain. +Run the supplied function in the context of the domain, implicitly +binding all event emitters, timers, and lowlevel requests that are +created in that context. Optionally, arguments can be passed to +the function. -If the domain on which `exit` is called has been disposed, `exit` will return -without exiting the domain. +This is the most basic way to use a domain. -### domain.dispose() +Example: -> Stability: 0 - Deprecated. Please recover from failed IO actions -> explicitly via error event handlers set on the domain. +```js +const domain = require('domain'); +const fs = require('fs'); +const d = domain.create(); +d.on('error', (er) => { + console.error('Caught error!', er); +}); +d.run(() => { + process.nextTick(() => { + setTimeout(() => { // simulating some various async stuff + fs.open('non-existent file', 'r', (er, fd) => { + if (er) throw er; + // proceed... + }); + }, 100); + }); +}); +``` -Once `dispose` has been called, the domain will no longer be used by callbacks -bound into the domain via `run`, `bind`, or `intercept`, and a `'dispose'` event -is emitted. +In this example, the `d.on('error')` handler will be triggered, rather +than crashing the program. [`domain.add(emitter)`]: #domain_domain_add_emitter [`domain.bind(callback)`]: #domain_domain_bind_callback |