A strongly typed event emitter

Example

import { EventBus, event } from '@knicola/minibus'

const bus = new EventBus()

const TestEvent = event<string>('test')

bus.subscribe(TestEvent, (data) => {
console.log(data)
})

bus.dispatch(TestEvent, 'Hello World!')

Hierarchy

  • EventBus

Constructors

Methods

  • Dispatch a event

    Type Parameters

    • TData

    Parameters

    • ev: Event<TData>
    • data: TData

      The data to dispatch with the event

    Returns void

  • Unsubscribe all handlers from a event or all messages

    Parameters

    • Optional ev: Event<unknown>

      The event to unsubscribe from

    Returns void

Generated using TypeDoc