温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/diagnostics_channel/Channel/runStores
点击访问原文链接

Channel.runStores method | Node.js diagnostics_channel module | Bun

Channel.runStores method | Node.js diagnostics_channel module | BunBuildDocsReferenceGuidesBlogDiscord/node:diagnostics_channel/Channel/runStoresMrunStores

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:diagnostics_channel/Channel/runStoresMrunStores

method

diagnostics_channel.Channel.runStores { const parent = store.getStore(); return new Span(message, parent); }); channel.runStores({ some: 'message' }, () => { store.getStore(); // Span({ some: 'message' }) }); ```" data-algolia-static="false" data-algolia-merged="false" data-type="Method">runStoresThisArg = any, Args extends any[] = any[], Result = any>(context: ContextType,fn: (this: ThisArg, ...args: Args) => Result,thisArg?: ThisArg,...args: Args): Result;Applies the given data to any AsyncLocalStorage instances bound to the channel for the duration of the given function, then publishes to the channel within the scope of that data is applied to the stores.

If a transform function was given to channel.bindStore(store) it will be applied to transform the message data before it becomes the context value for the store. The prior storage context is accessible from within the transform function in cases where context linking is required.

The context applied to the store should be accessible in any async code which continues from execution which began during the given function, however there are some situations in which context loss may occur.

import diagnostics_channel from 'node:diagnostics_channel'; import { AsyncLocalStorage } from 'node:async_hooks'; const store = new AsyncLocalStorage(); const channel = diagnostics_channel.channel('my-channel'); channel.bindStore(store, (message) => { const parent = store.getStore(); return new Span(message, parent); }); channel.runStores({ some: 'message' }, () => { store.getStore(); // Span({ some: 'message' }) }); @param contextMessage to send to subscribers and bind to stores

@param fnHandler to run within the entered storage context

@param thisArgThe receiver to be used for the function call.

@param argsOptional arguments to pass to the function.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco

We're hiring →

智能索引记录