Channels
5.19.0The Glue42 Channels are globally accessed named contexts that allow users to dynamically group applications, instructing them to work over the same shared data object. Assign a Glue42 enabled app to a Channel through the Channel Selector of the Glue42 Window:
When applications are on the same Channel, they share a context data object which they can monitor and/or update. See below how applications interact with each other using the Glue42 Channels:
The Channels API is accessible through the glue.channels
object.
APIobject
Description
Channels API
Methods
addmethod
Signature
(info: ChannelContext) => Promise<ChannelContext>
Description
Adds a new channel.
Available since version Glue42 3.18
Parameters
Name | Type | Required | Description |
---|---|---|---|
info | ChannelContext | The initial channel context. |
allmethod
Signature
() => Promise<string[]>
Description
Returns a list of all channel names.
getmethod
Signature
(name: string) => Promise<ChannelContext>
Description
Returns the context of a given channel.
Parameters
Name | Type | Required | Description |
---|---|---|---|
name | string | The name of the channel whose context to return. |
getMymethod
Signature
() => Promise<ChannelContext>
Description
Returns the context of the current channel.
Available since version 5.5.9
getWindowsOnChannelmethod
Signature
(channel: string) => Promise<GDWindow[]>
Description
Returns all windows on a give channel
Available since version Glue42 3.12
Parameters
Name | Type | Required | Description |
---|---|---|---|
channel | string |
getWindowsWithChannelsmethod
Signature
(filter?: WindowWithChannelFilter) => Promise<WindowOnChannelInfo[]>
Description
Returns channel enabled windows together with their current channel. If no filter is set will return all channel enabled windows.
Available since version Glue42 3.12
Parameters
Name | Type | Required | Description |
---|---|---|---|
filter | WindowWithChannelFilter | if set will limit the result to windows matching the criteria |
joinmethod
Signature
(name: string, windowId?: string) => Promise<void>
Description
Joins a new channel by name. Leaves the current channel.
Parameters
Name | Type | Required | Description |
---|---|---|---|
name | string | The name of the channel to join. |
|
windowId | string | If supplied will act on the specified window, not the current one |
leavemethod
Signature
(windowId?: string) => Promise<void>
Description
Leaves the current channel.
Parameters
Name | Type | Required | Description |
---|---|---|---|
windowId | string | If supplied will act on the specified window, not the current one |
listmethod
mymethod
Signature
() => string
Description
Returns the name of the current channel.
onChangedmethod
Signature
(callback: (channel: string) => void) => () => void
Description
Subscribes for the event which fires when a Channel is changed. Returns an unsubscribe function.
Parameters
Name | Type | Required | Description |
---|---|---|---|
callback | (channel: string) => void | Callback function to handle channel changes. |
publishmethod
Signature
(data: any, name?: string) => Promise<void>
Description
Updates the context of the current or a given channel.
Parameters
Name | Type | Required | Description |
---|---|---|---|
data | any | Data object with which to update the channel context. |
|
name | string | The name of the channel to be updated. If not provided will update the current channel. |
removemethod
Signature
(channel: string) => Promise<void>
Description
Removes a channel.
Available since version Glue42 3.18
Parameters
Name | Type | Required | Description |
---|---|---|---|
channel | string | The name of the Channel to remove. |
subscribemethod
Signature
(callback: (data: any, context: ChannelContext, updaterId: string) => void) => () => void
Description
Subscribes for data updates of the current Channel. Persisted after a Channel change. Returns an unsubscribe function.
Parameters
Name | Type | Required | Description |
---|---|---|---|
callback | (data: any, context: ChannelContext, updaterId: string) => void | Callback function to handle the received data. |
subscribeFormethod
Signature
(name: string, callback: (data: any, context: ChannelContext, updaterId: string) => void) => Promise<() => void>
Description
Subscribes for data updates of a specified Channel. Returns a Promise
that resolves with an unsubscribe function.
Parameters
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. |
ChannelContextobject
Description
Channel context object.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
data | any | Channel data. |
||
meta | any | Channel meta data (display name, color, image, etc.) |
||
name | string | Unique name of the context. |
WindowOnChannelInfoobject
Description
Information about a GDWindow that is channel enabled channel
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
application | string | |||
channel | string | |||
window | GDWindow |
WindowWithChannelFilterobject
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
application | string | |||
channels | string[] | |||
windowIds | string[] |