Kit
Interfaces

DataPublisher

Represents an object with an on function that you can call to subscribe to certain data over a named channel.

Example

let dataPublisher: DataPublisher<{ error: SolanaError }>;
dataPublisher.on('data', handleData); // ERROR. `data` is not a known channel name.
dataPublisher.on('error', e => {
    console.error(e);
}); // OK.

Type Parameters

Type ParameterDefault type
TDataByChannelName extends Record<string, unknown>Record<string, unknown>

Methods

on()

on<TChannelName>(channelName, subscriber, options?): UnsubscribeFn

Call this to subscribe to data over a named channel.

Type Parameters

Type Parameter
TChannelName extends string | number | symbol

Parameters

ParameterTypeDescription
channelNameTChannelNameThe name of the channel on which to subscribe for messages
subscriber(data) => voidThe function to call when a message becomes available
options?{ signal: AbortSignal; }-
options.signal?AbortSignalAn abort signal you can fire to unsubscribe

Returns

UnsubscribeFn

A function that you can call to unsubscribe

On this page