Skip to main content

Class: CdcEmitter

Defined in: src/realtime/CdcEmitter.ts:27

Change Data Capture (CDC) emitter and subscriber.

Bridges database real-time notifications (PostgreSQL LISTEN/NOTIFY, MySQL binlog triggers, MSSQL CDC) to in-process event handlers and EntityEventBus instances.

Constructors​

Constructor​

new CdcEmitter(eventBus?): CdcEmitter

Defined in: src/realtime/CdcEmitter.ts:33

Parameters​

ParameterType
eventBus?EntityEventBus

Returns​

CdcEmitter

Methods​

publish()​

publish<T>(event): Promise<void>

Defined in: src/realtime/CdcEmitter.ts:39

Publishes a Change Data Capture event to all matching subscribers and optionally bridges it to an attached EntityEventBus.

Type Parameters​

Type ParameterDefault type
Tany

Parameters​

ParameterType
eventCdcEvent<T>

Returns​

Promise<void>


subscribe()​

subscribe<T>(filterOrTable, handler): () => void

Defined in: src/realtime/CdcEmitter.ts:66

Subscribes to CDC events matching a filter object or table name. Returns an unsubscribe function.

Type Parameters​

Type ParameterDefault type
Tany

Parameters​

ParameterType
filterOrTablestring | CdcSubscriptionFilter
handlerCdcHandler<T>

Returns​

() => void


on()​

on<T>(table, handler): () => void

Defined in: src/realtime/CdcEmitter.ts:85

Subscribes to events for a specific table name.

Type Parameters​

Type ParameterDefault type
Tany

Parameters​

ParameterType
tablestring
handlerCdcHandler<T>

Returns​

() => void


parsePostgresPayload()​

static parsePostgresPayload(rawPayload): CdcEvent<any> | null

Defined in: src/realtime/CdcEmitter.ts:92

Helper that parses a PostgreSQL LISTEN/NOTIFY JSON payload into a typed CdcEvent.

Parameters​

ParameterType
rawPayloadstring

Returns​

CdcEvent<any> | null

Properties​

eventBus?​

readonly optional eventBus?: EntityEventBus

Defined in: src/realtime/CdcEmitter.ts:33