Files
triggerdotdev--trigger.dev/apps/webapp/app/utils/singleton.ts
T
2026-07-13 13:32:57 +08:00

7 lines
239 B
TypeScript

export function singleton<T>(name: string, getValue: () => T): T {
const thusly = globalThis as any;
thusly.__trigger_singletons ??= {};
thusly.__trigger_singletons[name] ??= getValue();
return thusly.__trigger_singletons[name];
}