14 lines
489 B
TypeScript
14 lines
489 B
TypeScript
import * as plugins from './logcontext.plugins.js';
|
|
import { AsyncStore } from './logcontext.classes.asyncstore.js';
|
|
|
|
export class AsyncContext {
|
|
private context = new plugins.simpleAsyncContext.AsyncContext.Variable<AsyncStore>();
|
|
public store = new AsyncStore();
|
|
public runScoped(functionArg: (storeArg: AsyncStore) => Promise<void>) {
|
|
this.context.run(this.store, async () => {
|
|
const childStore = new AsyncStore(this.store);
|
|
functionArg(childStore)
|
|
});
|
|
}
|
|
}
|