io.channels API
The Channels API for user-driven, color-coded data linking between windows.
join()
io.channels.join(channelName: string): Promise<void>
Example
await io.channels.join("Red");leave()
io.channels.leave(): Promise<void>
my()
Returns the name of the current channel, or undefined if not joined.
io.channels.my(): string | undefined
publish()
Publish data to the currently joined channel.
io.channels.publish(data: object, channelName?: string): Promise<void>
Example
await io.channels.publish({
type: "fdc3.instrument",
id: { ticker: "AAPL" },
name: "Apple Inc.",
});subscribe()
Subscribe to data on the current channel. The handler fires on every publish.
io.channels.subscribe(callback: (data, context, updaterId) => void): void
| Parameter | Type | Description |
|---|---|---|
callbackrequired | function | Receives: data (published object), context (full channel context), updaterId (publisher's peer ID). |
Example
io.channels.subscribe((data, _ctx, updaterId) => {
const isMe = io.interop.instance.peerId === updaterId;
if (!isMe) console.log("Received:", data);
});list()
Returns all available channels with their metadata.
io.channels.list(): Promise<Channel[]>
onChanged()
Called when the user switches to a different channel.
io.channels.onChanged(callback: (channelName: string) => void): void