iniquity

A re-imagining of the iconic BBS software.

View on GitHub

Class: IQEventBus

core/events.IQEventBus

IQEventBus - Global event bus for BBS applications

Provides a publish/subscribe pattern for decoupled event handling. Events can be emitted from anywhere and handlers will be called regardless of the current menu or screen state.

Table of contents

Constructors

Methods

Constructors

constructor

new IQEventBus()

Methods

clearQueue

clearQueue(): void

Clear all pending events from the queue

Returns

void

Defined in

core/src/events.ts:200


emit

emit(event, data?, source?): void

Emit an event (queues for processing)

Parameters

Name Type Description
event string Event type to emit
data? any Optional data payload
source? string Optional source identifier

Returns

void

Defined in

core/src/events.ts:139


emitSync

emitSync(event, data?, source?): Promise<void>

Emit an event and process immediately (synchronous dispatch)

Parameters

Name Type Description
event string Event type to emit
data? any Optional data payload
source? string Optional source identifier

Returns

Promise<void>

Defined in

core/src/events.ts:157


getPendingCount

getPendingCount(): number

Get the number of pending events

Returns

number

Defined in

core/src/events.ts:193


getRegisteredEvents

getRegisteredEvents(): string[]

Get list of registered event types

Returns

string[]

Defined in

core/src/events.ts:215


hasHandlers

hasHandlers(event): boolean

Check if an event has any handlers

Parameters

Name Type
event string

Returns

boolean

Defined in

core/src/events.ts:222


hasPendingEvents

hasPendingEvents(): boolean

Check if there are pending events in the queue

Returns

boolean

Defined in

core/src/events.ts:186


off

off(event, handler?): void

Unsubscribe from an event

Parameters

Name Type Description
event string Event type to unsubscribe from
handler? IQEventHandler Specific handler to remove (if omitted, removes all handlers for event)

Returns

void

Defined in

core/src/events.ts:108


on

on(event, handler, options?): () => void

Subscribe to an event

Parameters

Name Type Description
event string Event type to listen for (use ‘*’ for all events)
handler IQEventHandler Function to call when event is emitted
options? IQEventOptions Subscription options

Returns

fn

Unsubscribe function

▸ (): void

Subscribe to an event

Returns

void

Unsubscribe function

Defined in

core/src/events.ts:69


once

once(event, handler): () => void

Subscribe to an event (fires only once)

Parameters

Name Type Description
event string Event type to listen for
handler IQEventHandler Function to call when event is emitted

Returns

fn

Unsubscribe function

▸ (): void

Subscribe to an event (fires only once)

Returns

void

Unsubscribe function

Defined in

core/src/events.ts:99


processQueue

processQueue(): Promise<void>

Process all queued events Called from the menu event loop to process pending events

Returns

Promise<void>

Defined in

core/src/events.ts:172


removeAllHandlers

removeAllHandlers(): void

Remove all handlers for all events

Returns

void

Defined in

core/src/events.ts:207