File tree 1 file changed +4
-3
lines changed
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ this time will print the stack trace and exit. See
147
147
Creating an async resource within the ` onPropagate ` callback will result in
148
148
a recursive call to ` onPropagate ` .
149
149
150
- ### ` asyncLocalStorage.bind(fn, thisArg) `
150
+ ### ` asyncLocalStorage.bind(fn [ , thisArg] ) `
151
151
152
152
<!-- YAML
153
153
added: REPLACEME
@@ -167,13 +167,14 @@ the `AsyncResource` to which the function is bound.
167
167
added: REPLACEME
168
168
-->
169
169
170
- Returns a callback that captures the current async context and invokes a callback passed into it within the captured async context.
170
+ Returns a callback that captures the current async context and invokes a callback passed into it
171
+ within the captured async context.
171
172
172
173
``` js
173
174
const asyncLocalStorage = new AsyncLocalStorage ();
174
175
const runInAsyncScope = asyncLocalStorage .run (123 , () => als .snapshot ());
175
176
const result = asyncLocalStorage .run (321 , () => runInAsyncScope (() => asyncLocalStorage .getStore ()));
176
- console .log (result) // returns 123
177
+ console .log (result); // returns 123
177
178
```
178
179
179
180
AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple async context tracking purposes, for example:
You can’t perform that action at this time.
0 commit comments