io.channelsAPIinterface
Channels API.
Properties (1)
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| mode⚓︎ | Mode | "single" | Retrieves the current Channel mode (single or multi Channel). Set by the io.Connect framework based on configuration. io.Connect Browser 3.5 |
24 Methods
add()⚓︎
(info: ChannelDefinition) => Promise<ChannelContext>
Adds a new Channel.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| info⚓︎ | ChannelDefinition | Initial Channel context. |
all()⚓︎
() => Promise<string[]>
Returns a list of all channel names.
Returns
Promise that resolves with the list of all channel names.
clearChannelData()⚓︎
(name?: string) => Promise<void>
Clears the context data of the current Channel. The data property of the Channel context is set to an empty object.
Pass a Channel name as an argument to clear the data of a specific Channel.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| name⚓︎ | string | x | Name of the Channel whose context data to clear. |
get()⚓︎
(name: string, options?: FDC3Options) => Promise<ChannelContext>
Returns the context of a given channel.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| name⚓︎ | string | The name of the channel whose context to return. |
|
| options⚓︎ | FDC3Options | x | Settings for retrieving an FDC3 context published in the io.Connect Channel. |
Returns
Promise that resolves with the context of the given channel.
getMy()⚓︎
(options?: FDC3Options) => Promise<ChannelContext | undefined>
Retrieves the context of the current Channel.
It's recommended to use the getMyChannels() method instead, which can retrieve the contexts of the currently joined Channels both in single and in multi Channel mode.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| options⚓︎ | FDC3Options | x | Settings for retrieving an FDC3 context published in the io.Connect Channel. |
getMyChannels()⚓︎
() => Promise<ChannelContext[]>
Retrieves a list with the contexts of the current Channels. Can be used both in single and in multi Channel mode. If used in single Channel mode, the returned array will always contain a single member if the window is joined to a Channel, or will be empty otherwise.
io.Connect Browser 3.5getRestrictions()⚓︎
(windowId?: string) => Promise<Restrictions>
Retrieves the restrictions applied to the current window for publishing or subscribing to Channels. Pass a window ID to retrieve the restrictions for the specified window.
io.Connect Browser 3.3Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| windowId⚓︎ | string | x | ID of the window for which to retrieve the applied restrictions for publishing or subscribing to Channels. |
getWindowsOnChannel()⚓︎
Retrieves all windows on a specified Channel.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| channel⚓︎ | string | The name of the Channel for which windows should be returned. |
Returns
Promise that resolves with the list of all windows on a specified Channel.
getWindowsWithChannels()⚓︎
(filter?: WindowWithChannelFilter) => Promise<WindowOnChannelInfo[]>
Retrieves all windows that can use Channels together with their current Channel.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| filter⚓︎ | WindowWithChannelFilter | x | Filter describing which windows to retrieve. If no filter is supplied, will return all windows that can use Channels. |
Returns
Promise that resolves with the list of all windows that can use Channels together with their current Channel.
join()⚓︎
(name: string, windowId?: string) => Promise<void>
Joins a new channel by name. Leaves the current channel.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| name⚓︎ | string | The name of the channel to join. |
|
| windowId⚓︎ | string | x | ID of a window which to join to a Channel. If not provided, will join the current window to the specified Channel. |
Returns
Promise that resolves when the channel has been joined.
leave()⚓︎
(options?: LeaveOptions) => Promise<void>
Removes the current or a specified window from the current or a specified Channel.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| options⚓︎ | LeaveOptions | x | Options for leaving Channels. |
list()⚓︎
() => Promise<ChannelContext[]>
Returns a list of all channel contexts.
Returns
Promise that resolves with the list of all channel contexts.
my()⚓︎
() => string
Retrieves the name of the current Channel.
It's recommended to use the myChannels() method instead, which can retrieve the names of the currently joined Channels both in single and in multi Channel mode.
myChannels()⚓︎
() => string[]
Retrieves a list with the names of the current Channels. Can be used both in single and in multi Channel mode. If used in single Channel mode, the returned array will always contain a single member if the window is joined to a Channel, or will be empty otherwise.
io.Connect Browser 3.5onChanged()⚓︎
(callback: (channel: string) => void) => UnsubscribeFunction
Notifies when the current window joins or leaves a Channel. Returns an unsubscribe function.
It's recommended to use the onChannelsChanged() method instead, which can handle Channel changes both in single and in multi Channel mode.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| callback⚓︎ | (channel: string) => void | Callback function for handling the event. Receives as an argument the name of the newly joined Channel. If the window leaves a Channel without joining a new one, the argument will be |
onChannelsChanged()⚓︎
(callback: (channels: string[]) => void) => UnsubscribeFunction
Notifies when the current window joins or leaves a Channel. Can be used both in single and in multi Channel mode. If used in single Channel mode, when the window joins a Channel, the array argument passed to the callback for handling the event will always contain a single member; when the window leaves the current Channel, the array will be empty. Returns an unsubscribe function.
io.Connect Browser 3.5Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| callback⚓︎ | (channels: string[]) => void | Callback function for handling the event. Receives a list with the names of the currently joined Channels as an argument. |
publish()⚓︎
(data: any, options?: string | PublishOptions) => Promise<void>
Updates the context of the current or a given channel.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| data⚓︎ | any | Data object with which to update the channel context. |
|
| options⚓︎ | string | PublishOptions | x | The name of the Channel to update, or an object containing the name of the Channel to update and a flag indicating whether the published data is an FDC3 context. If no options are provided, the current Channel will be updated. |
Returns
Promise that resolves when the data has been published.
remove()⚓︎
(name: string) => Promise<void>
Removes a Channel.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| name⚓︎ | string | The name of the Channel to remove. |
restrict()⚓︎
(config: ChannelRestrictions) => Promise<void>
Prevents or allows the current or another window to publish or subscribe to a specific Channel.
io.Connect Browser 3.3Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| config⚓︎ | ChannelRestrictions | x |
restrictAll()⚓︎
(restrictions: RestrictionsConfig) => Promise<void>
Prevents or allows the current or another window to publish or subscribe to all Channels.
io.Connect Browser 3.3Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
| restrictions⚓︎ | RestrictionsConfig | Restrictions for publishing or subscribing to all Channels. |
setPath()⚓︎
Sets a specified path within the Channel context to the provided value. If the path doesn't exist, it will be created.
io.Connect Browser 4.0Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| path⚓︎ | Contexts.PathValue | Object containing the path to update and the value with which to update it. The path must be specified as a dot-separated string (e.g., |
|
| name⚓︎ | string | x | Name of the Channel to update. If not specified, will update the current Channel. |
setPaths()⚓︎
Sets a list of specified paths within the Channel context to the provided values. If a path doesn't exist, it will be created.
io.Connect Browser 4.0Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| paths⚓︎ | Contexts.PathValue[] | List of objects each containing a path to update and the value with which to update it. The path must be specified as a dot-separated string (e.g., |
|
| name⚓︎ | string | x | Name of the Channel to update. If not specified, will update the current Channel. |
subscribe()⚓︎
(callback: (data: any, context: ChannelContext, updaterId: string) => void, options?: FDC3Options) => UnsubscribeFunction
Tracks the data in the current channel. Persisted after a channel change. The callback isn't called when you publish the data.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
| callback⚓︎ | (data: any, context: ChannelContext, updaterId: string) => void | Callback function to handle the received data. |
|
| options⚓︎ | FDC3Options | x | Settings for subscribing to an FDC3 context published in the io.Connect Channel. |
Returns
Unsubscribe function.
subscribeFor()⚓︎
(name: string, callback: (data: any, context: ChannelContext, updaterId: string) => void, options?: FDC3Options) => Promise<UnsubscribeFunction>
Tracks the data in a given channel.
Parameters (3)
| Name | Type | Required | Description |
|---|---|---|---|
| name⚓︎ | string | The channel to track. |
|
| callback⚓︎ | (data: any, context: ChannelContext, updaterId: string) => void | Callback function to handle the received data. |
|
| options⚓︎ | FDC3Options | x | Settings for subscribing to an FDC3 context published in the io.Connect Channel. |
Returns
Promise that resolves with an unsubscribe function.