function EventsPlugin
Since 0.1.0
EventsPlugin(options?: EventsPluginOptions): IPlugin

Creates the EventsPlugin.

Registers an IEventBus under CAPABILITIES.EVENTS. Single instance only (no name option — adding one would be a dead option per CLAUDE.md).

Examples

Example 1

import { EventsPlugin } from '@setu-ts/events-plugin';

app.register(EventsPlugin({
  async: true,
  handlers: [
    { type: 'user-created', handler: new UserCreatedEventHandler() },
    { type: 'order-placed', handler: createOrderPlacedEventHandler },
  ],
}));

handlers accepts an instance or a RegistryFactory ((services: IServiceRegistry) => IEventHandler). A factory is resolved at onInit — the first phase at which the registry holds every capability — and subscribes through the same subscribeHandler the instance arm uses. Instance handlers keep their register() timing.

Parameters

optional
options: EventsPluginOptions

Plugin configuration

Return Type

IPlugin

The plugin instance

Usage

import { EventsPlugin } from "events-plugin/src/index.ts";