Creates a new RunResult instance.
The framework logger for runtime diagnostics
The central store containing all registered tasks, events, resources
Handles event emission and hook execution
Executes tasks with middleware and validation
Callback to clean up all resources during disposal
Emits an event to trigger all registered hooks listening for it.
Events are emitted synchronously or asynchronously depending on hook configuration.
Hooks execute in order based on their order() value (lower runs first).
// Basic emission
await runtime.emitEvent(userRegistered, { userId: "123", email: "a@b.com" });
// With report for hook failure tracking
const report = await runtime.emitEvent(notify, undefined, { report: true });
if (report.failedListeners.length > 0) {
console.error("Failed hooks:", report.failedListeners);
}
ReadonlyloggerFramework logger for diagnostics and debugging. Use this for logging within tasks or hooks.
ReadonlystoreCentral store containing all registered definitions. Provides access to tasks, events, resources, and their metadata.
Returns the root value initialized by the root resource. Only available after the root resource has been initialized.
Disposes the runtime and all registered resources.
Disposal executes in reverse initialization order:
dispose methods are calledAfter disposal, any further operations will throw. Safe to call multiple times (subsequent calls return immediately).
Promise that resolves when disposal is complete
Initializes (if not already) and returns the value of a resource on-demand.
This method is useful when:
The resource definition or resource ID string
The initialized value of the resource (unwrapped if Promise-based)
Retrieves the configuration that was passed to a resource.
This returns the config object (the input), not the initialized value.
Use getResourceValue() to get the initialized value.
The resource definition or resource ID string
The config object passed when registering the resource
Synchronously retrieves the initialized value of a resource.
The resource must have been initialized (either at startup or via lazy loading).
For resources not initialized at startup, use getLazyResourceValue() instead.
The resource definition or resource ID string
The initialized value of the resource (unwrapped if Promise-based)
Returns the configuration passed to the root resource.
The root resource configuration
Returns the initialized value of the root resource.
This is the value returned by the root resource's init function.
The root must have been fully initialized before calling this.
The root resource's initialized value
Executes a registered task within the runtime context.
The task runs through its full middleware pipeline including:
Configures lazy loading options for resources. Used to enable on-demand resource initialization.
Lazy mode configuration
Sets the root value after the root resource initializes.
The initialized root value
RunResult represents the runtime instance after executing
run(root). It provides access to tasks, events, resources, and lifecycle management.Key features:
runTask()emitEvent()getResourceValue()/getLazyResourceValue()getRootValue(),getRootConfig(),getRootId()dispose()Example