Skip to main content

@boost/event

build status npm version

A strict event system with multiple emitter patterns.

import { Event } from '@boost/event';

const event = new Event<[string, number]>('name');

event.listen(listener);
event.emit(['abc', 123]);

Features

  • Isolated event instances for proper type-safety.
  • Supports 4 event types: standard, bail, concurrent, and waterfall.
  • Listener scopes for targeted emits.

Installation

yarn add @boost/event

Documentation

Index

Type Aliases

EventErrorCode

EventErrorCode: keyof typeof errors

Listener

Listener<A, R>: A extends [infer A1, infer A2, infer A3, infer A4, infer A5] ? (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => R : A extends [infer A1, infer A2, infer A3, infer A4] ? (a1: A1, a2: A2, a3: A3, a4: A4) => R : A extends [infer A1, infer A2, infer A3] ? (a1: A1, a2: A2, a3: A3) => R : A extends [infer A1, infer A2] ? (a1: A1, a2: A2) => R : A extends [infer A1] ? (a1: A1) => R : A extends unknown[] ? (...args: A) => R : never

Type parameters

  • A: unknown[]
  • R

Unlistener

Unlistener: () => void

WildstarScope

WildstarScope: *

Variables

constEVENT_NAME_PATTERN

EVENT_NAME_PATTERN: RegExp = ...

constEventError

EventError: new (code: LISTENER_INVALID | NAME_INVALID, params?: unknown[]) => Error & ScopedError<LISTENER_INVALID | NAME_INVALID> = ...

constWILDCARD_SCOPE

WILDCARD_SCOPE: * = '*'