asyncLocalStorage.run(store, callback[, ...args])
store
<any>callback
<Function>...args
<any>
可选地,参数可以传给函数。
示例:
const store = { id: 2 };
try {
asyncLocalStorage.run(store, () => {
asyncLocalStorage.getStore(); //
throw new Error();
});
} catch (e) {
asyncLocalStorage.getStore(); //
//
}