AIDK API Reference / aidk-client / Channel
Interface: Channel<TIncoming, TOutgoing> ​
Defined in: packages/client/src/channel.ts:53
Connected channel instance
Type Parameters ​
| Type Parameter | Default type |
|---|---|
TIncoming extends Record<string, unknown> | Record<string, unknown> |
TOutgoing extends Record<string, unknown> | Record<string, unknown> |
Properties ​
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
connected | readonly | boolean | Whether the channel is connected | packages/client/src/channel.ts:61 |
name | readonly | string | Channel name | packages/client/src/channel.ts:58 |
Methods ​
disconnect() ​
ts
disconnect(): void;Defined in: packages/client/src/channel.ts:86
Disconnect from the channel
Returns ​
void
on() ​
ts
on<K>(eventType: K, handler: (payload: TIncoming[K], event: ChannelEvent) => void): () => void;Defined in: packages/client/src/channel.ts:67
Subscribe to an incoming event type
Type Parameters ​
| Type Parameter |
|---|
K extends string | number | symbol |
Parameters ​
| Parameter | Type |
|---|---|
eventType | K |
handler | (payload: TIncoming[K], event: ChannelEvent) => void |
Returns ​
Unsubscribe function
ts
(): void;Returns ​
void
onAny() ​
ts
onAny(handler: (event: ChannelEvent) => void): () => void;Defined in: packages/client/src/channel.ts:76
Subscribe to all incoming events
Parameters ​
| Parameter | Type |
|---|---|
handler | (event: ChannelEvent) => void |
Returns ​
Unsubscribe function
ts
(): void;Returns ​
void
send() ​
ts
send<K>(eventType: K, payload: TOutgoing[K]): Promise<unknown>;Defined in: packages/client/src/channel.ts:81
Send an outgoing event
Type Parameters ​
| Type Parameter |
|---|
K extends string | number | symbol |
Parameters ​
| Parameter | Type |
|---|---|
eventType | K |
payload | TOutgoing[K] |
Returns ​
Promise<unknown>