API reference > @kontsedal/olas-core > createEmitter
createEmitter() function
Create a standalone emitter. Handlers persist until explicitly unsubscribed (or the emitter is disposed). Use this for emitters that live outside any single controller — typically in deps. Use ctx.emitter() for emitters that should auto-clean with a controller.
Pass onError to receive emit-time handler throws (spec §20.6 — one throwing handler must not block the rest of the fan-out). ctx.emitter() wires this to the root's onError so deps-level emitters get isolation by default when constructed via ctx.
Signature:
typescript
declare function createEmitter<T = void>(options?: {
onError?: EmitterErrorReporter;
}): Emitter<T>;Parameters
Parameter | Type | Description |
|---|---|---|
options | { onError?: EmitterErrorReporter; } | (Optional) |
Returns:
Emitter<T>