Channels
5.24.0The Glue42 Channels are globally accessed named contexts that allow users to dynamically group apps, instructing them to work over the same shared data object. When apps are on the same Channel, they share a context data object which they can monitor and/or update.
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 | Initial Channel context. |
allmethod
Signature
() => Promise<string[]>
Description
Retrieves a list of all Channel names.
getmethod
Signature
(name: string) => Promise<ChannelContext>
Description
Retrieves the context of a specified Channel.
Parameters
Name | Type | Required | Description |
---|---|---|---|
name | string | The name of the Channel whose context to retrieve. |
getMymethod
getWindowsOnChannelmethod
Signature
(channel: string) => Promise<GDWindow[]>
Description
Retrieves all windows on a specified Channel.
Available since version Glue42 3.12
Parameters
Name | Type | Required | Description |
---|---|---|---|
channel | string |
getWindowsWithChannelsmethod
Signature
(filter?: WindowWithChannelFilter) => Promise<WindowOnChannelInfo[]>
Description
Retrieves all windows that can use Channels together with their current Channel.
Available since version Glue42 3.12
Parameters
Name | Type | Required | Description |
---|---|---|---|
filter | WindowWithChannelFilter | Filter describing which windows to retrieve. If no filter is supplied, will return all windows that can use Channels. |
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 | ID of a window which to join to a Channel. If not provided, will join the current window to the specified Channel. |
leavemethod
Signature
(windowId?: string) => Promise<void>
Description
Leaves the current Channel.
Parameters
Name | Type | Required | Description |
---|---|---|---|
windowId | string | ID of a window which to force to leave a Channel. If not provided, will force the current window to leave the current Channel. |
listmethod
mymethod
Signature
() => string
Description
Retrieves the name of the current Channel.
onChangedmethod
Signature
(callback: (channel: string) => void) => () => void
Description
Notifies when a Channel is changed. Returns an unsubscribe function.
Parameters
Name | Type | Required | Description |
---|---|---|---|
callback | (channel: string) => void | Callback function for handling the event. |
publishmethod
Signature
(data: any, name?: string) => Promise<void>
Description
Updates the context of the current or a specified 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 update. 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
Describes a Channel context.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
data | any | Channel context data. |
||
meta | any | Channel meta data (display name, color, image and more). |
||
name | string | Unique name of the Channel context. |
WindowOnChannelInfoobject
Description
Describes a Glue42 Window that can use Channels.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
application | string | The name of the app of which the Glue42 Window is an instance. |
||
channel | string | The current Channel of the Glue42 Window. May be |
||
window | GDWindow | The Glue42 Window object. |
WindowWithChannelFilterobject
Description
Filter that will be applied when looking for Glue42 Windows that can use Channels.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
application | string | Will retrieve only Glue42 Windows that are instances of the specified app. |
||
channels | string[] | Will retrieve all Glue42 Windows that are on the specified Channel. |
||
windowIds | string[] | IDs of Glue42 Windows which to retrieve. |