Skip to content

getDefaultRuntime

Stable · since 0.1.0

Returns the global default Runtime, creating it lazily on first call. This is the runtime every binding falls back to when no <TriggerRuntimeProvider> is in scope. Most apps never call it directly — it’s an implementation detail of the hooks.

The function is idempotent. The first call constructs a runtime with default options; every subsequent call returns the same instance until setDefaultRuntime replaces it.

import { getDefaultRuntime } from '@triggery/core';
function getDefaultRuntime(): Runtime;

None.

The single shared Runtime instance. Subsequent calls return the same reference (===).

import { createTriggerfunction createTrigger<S extends TriggerSchema>(config: CreateTriggerConfig<S>, runtime?: Runtime): Trigger<S>
Imperative form. Pass the trigger config; returns a live `Trigger<S>` registered with the runtime. The chainable builder form lives in the `@triggery/core/builder` subpath — import from there if you want `createTrigger<S>().require(...).handle(...)` with auto-narrowing.
, getDefaultRuntimefunction getDefaultRuntime(): Runtime } from '@triggery/core';
createTrigger
createTrigger<{
    events: {
        ping: number;
    };
}>(config: CreateTriggerConfig<{
    events: {
        ping: number;
    };
}>, runtime?: Runtime): Trigger<{
    events: {
        ping: number;
    };
}>
Imperative form. Pass the trigger config; returns a live `Trigger<S>` registered with the runtime. The chainable builder form lives in the `@triggery/core/builder` subpath — import from there if you want `createTrigger<S>().require(...).handle(...)` with auto-narrowing.
<{ events
events: {
    ping: number;
}
: { pingping: number: number } }>({
idid: string: 'demo:ping', eventsevents: readonly "ping"[]: ['ping'], handler
handler: TriggerHandler<{
    events: {
        ping: number;
    };
}, never>
({ event
event: {
    readonly name: "ping";
    readonly payload: number;
}
}) {
consolevar console: Console.logConsole.log(...data: any[]): void
The **`console.log()`** static method outputs a message to the console. [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
('ping', event
event: {
    readonly name: "ping";
    readonly payload: number;
}
.payloadpayload: number);
}, }); // In a WebSocket adapter, a service worker, or any non-React layer. getDefaultRuntimefunction getDefaultRuntime(): Runtime().firefunction fire(eventName: string, payload?: unknown): void
Fire an event asynchronously (through the scheduler).
('ping', 42);
import { getDefaultRuntimefunction getDefaultRuntime(): Runtime } from '@triggery/core';

export function dumpGraphfunction dumpGraph(): RuntimeGraph() {
  const runtimeconst runtime: Runtime = getDefaultRuntimefunction getDefaultRuntime(): Runtime();
  return runtimeconst runtime: Runtime.graphfunction graph(): RuntimeGraph
JSON-friendly snapshot of the trigger registry — for devtools, the CLI's `triggery graph` command, and tooling that introspects connections.
();
}
import { getDefaultRuntimefunction getDefaultRuntime(): Runtime } from '@triggery/core';

const aconst a: Runtime = getDefaultRuntimefunction getDefaultRuntime(): Runtime();
const bconst b: Runtime = getDefaultRuntimefunction getDefaultRuntime(): Runtime();
consolevar console: Console.logConsole.log(...data: any[]): void
The **`console.log()`** static method outputs a message to the console. [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
(aconst a: Runtime === bconst b: Runtime); // true — same instance