本文整理汇总了TypeScript中domain-context.set函数的典型用法代码示例。如果您正苦于以下问题:TypeScript set函数的具体用法?TypeScript set怎么用?TypeScript set使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: baseUrl
export function baseUrl(url?: string): string {
if (url) {
if (domain.active) {
// There's an active domain (e.g., in Node.js), so associate the base URL with it
domainContext.set(domainTaskStateKey, url);
} else {
// There's no active domain (e.g., in browser), so there's just one shared base URL
noDomainBaseUrl = url;
}
}
return domain.active ? domainContext.get(domainTaskStateKey) : noDomainBaseUrl;
}
示例2: codeToRun
domainContext.runInNewDomain(() => {
const state: DomainTasksState = {
numRemainingTasks: 0,
hasIssuedSuccessCallback: false,
completionCallback: domain.active.bind(completionCallback)
};
try {
domainContext.set(domainTasksStateKey, state);
synchronousResult = codeToRun();
// If no tasks were registered synchronously, then we're done already
if (state.numRemainingTasks === 0 && !state.hasIssuedSuccessCallback) {
state.hasIssuedSuccessCallback = true;
state.completionCallback(/* error */ null);
}
} catch(ex) {
state.completionCallback(ex);
}
});