arvo-event-handler
    Preparing search index...

    Class SimpleEventBroker

    A simple event broker for handling local event-driven workflows within function scope. Ideal for composing function handlers and coordinating local business logic steps.

    Use SimpleEventBroker when you need:

    • Local event handling within a function's execution scope
    • Decoupling steps in a business process
    • Simple composition of handlers for a workflow
    • In-memory event management for a single operation

    Not suitable for:

    • Long-running processes or persistent event storage
    • Cross-process or distributed event handling
    • High-throughput event processing (>1000s events/sec)
    • Mission critical or fault-tolerant systems
    • Complex event routing or filtering

    Typical use cases:

    • Coordinating steps in a registration process
    • Managing validation and processing workflows
    • Decoupling business logic steps
    • Local event-driven state management
    // During a registration flow
    const broker = new SimpleEventBroker({ ... });

    broker.subscribe('validation.complete', async (event) => {
    // Handle validation results
    });

    broker.subscribe('user.created', async (event) => {
    // Handle user creation side effects
    });

    await broker.publish({
    to: 'validation.complete',
    payload: userData
    });
    Index

    Constructors

    Properties

    events: ArvoEvent<
        Record<string, any>,
        Record<string, string | number | boolean | null>,
        string,
    >[]

    Accessors

    Methods

    • Publish an event to subscribers

      Parameters

      • event: ArvoEvent

        Event to publish

      Returns Promise<void>

      Error if queue is full or event has no topic

    • Subscribe to a specific event type

      Parameters

      • topic: string

        Event type to subscribe to

      • handler: EventBusListener

        Function to handle the event

      • assertUnique: boolean = false

        Asserts the uniqne-ness of the handler. If true, then only one handler per topic otherwise, throws error

      Returns () => void

      Unsubscribe function