mirror of
https://github.com/zadam/trilium.git
synced 2026-06-19 11:41:58 +02:00
25 lines
553 B
TypeScript
25 lines
553 B
TypeScript
import { ExecutionContext } from "@triliumnext/core";
|
|
import clsHooked from "cls-hooked";
|
|
|
|
export const namespace = clsHooked.createNamespace("trilium");
|
|
|
|
export default class ClsHookedExecutionContext implements ExecutionContext {
|
|
|
|
get<T = any>(key: string): T | undefined {
|
|
return namespace.get(key);
|
|
}
|
|
|
|
set(key: string, value: any): void {
|
|
namespace.set(key, value);
|
|
}
|
|
|
|
reset(): void {
|
|
clsHooked.reset();
|
|
}
|
|
|
|
init<T>(callback: () => T): T {
|
|
return namespace.runAndReturn(callback);
|
|
}
|
|
|
|
}
|