Skip to main content

Class: TableEventBus

helpers.TableEventBus

TableEventBus provides a way to listen for: mutations, transfers, and changes to controller

Constructors

constructor

new TableEventBus(config?)

Create a TableEventBus instance with the specified connection configuration.

Parameters

NameTypeDescription
configPartial<Partial<ReadConfig & SignerConfig>>The connection configuration. This must include an ethersjs Signer. If passing the config from a pre-existing Database instance, it must have a non-null signer key defined.

Defined in

@tableland/sdk/src/helpers/subscribe.ts:77

Properties

config

Readonly config: Partial<ReadConfig & SignerConfig>

Defined in

@tableland/sdk/src/helpers/subscribe.ts:67


contracts

Readonly contracts: ContractMap

Defined in

@tableland/sdk/src/helpers/subscribe.ts:68


listeners

Readonly listeners: ListenerMap

Defined in

@tableland/sdk/src/helpers/subscribe.ts:69

Methods

_attachEmitter

_attachEmitter(contract, emitter, tableIdentifier): ContractEventListener[]

Parameters

NameType
contractTablelandTables
emitterEventEmitter
tableIdentifierTableIdentifier

Returns

ContractEventListener[]

Defined in

@tableland/sdk/src/helpers/subscribe.ts:224


_ensureListening

_ensureListening(listenerId, emitter): Promise<ContractEventListener[]>

Parameters

NameType
listenerIdstring
emitterEventEmitter

Returns

Promise<ContractEventListener[]>

Defined in

@tableland/sdk/src/helpers/subscribe.ts:214


_getContract

_getContract(chainId): Promise<TablelandTables>

Parameters

NameType
chainIdnumber

Returns

Promise<TablelandTables>

Defined in

@tableland/sdk/src/helpers/subscribe.ts:198


addListener

addListener(tableName): Promise<EventEmitter>

Start listening to the Registry Contract for events that are associated with a given table. There's only ever one "listener" for a table, but the emitter that Contract listener has can have as many event listeners as the environment supports.

Parameters

NameTypeDescription
tableNamestringThe full name of table that you want to listen for changes to.

Returns

Promise<EventEmitter>

Defined in

@tableland/sdk/src/helpers/subscribe.ts:97


addTableIterator

addTableIterator<T>(tableName): Promise<AsyncIterable<T>>

A simple wrapper around addListener that returns an async iterable which can be used with the for await ... of pattern.

Type parameters

Name
T

Parameters

NameTypeDescription
tableNamestringThe full name of table that you want to listen for changes to.

Returns

Promise<AsyncIterable<T>>

Defined in

@tableland/sdk/src/helpers/subscribe.ts:132


removeAllListeners

removeAllListeners(): void

Returns

void

Defined in

@tableland/sdk/src/helpers/subscribe.ts:163


removeListener

removeListener(params): void

Remove a listener (or iterator) based on chain and tableId

Parameters

NameTypeDescription
paramsTableIdentifierA TableIdentifier Object. Must have chainId and tableId keys.

Returns

void

Defined in

@tableland/sdk/src/helpers/subscribe.ts:145