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

Function registerGlobal

packages/core/src/v3/utils/globals.ts:12–28  ·  view source on GitHub ↗
(
  type: Type,
  instance: TriggerDotDevGlobalAPI[Type],
  allowOverride = false
)

Source from the content-addressed store, hash-verified

10const _global = _globalThis as TriggerDotDevGlobal;
11
12export function registerGlobal<Type extends keyof TriggerDotDevGlobalAPI>(
13 type: Type,
14 instance: TriggerDotDevGlobalAPI[Type],
15 allowOverride = false
16): boolean {
17 const api = (_global[GLOBAL_TRIGGER_DOT_DEV_KEY] = _global[GLOBAL_TRIGGER_DOT_DEV_KEY] ?? {});
18
19 if (!allowOverride && api[type]) {
20 // already registered an API of this type
21 const err = new Error(`trigger.dev: Attempted duplicate registration of API: ${type}`);
22 return false;
23 }
24
25 api[type] = instance;
26
27 return true;
28}
29
30export function getGlobal<Type extends keyof TriggerDotDevGlobalAPI>(
31 type: Type

Callers 6

setGlobalTaskLoggerMethod · 0.90
setGlobalClockMethod · 0.90
setGlobalTaskContextMethod · 0.90
setGlobalTaskCatalogMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…