MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / singleton

Function singleton

apps/webapp/app/utils/singleton.ts:1–6  ·  view source on GitHub ↗
(name: string, getValue: () => T)

Source from the content-addressed store, hash-verified

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

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…