ContextChannels

Context channels allow end-user filtering of context broadcasts. Each window is assigned to a particular context channel, and any broadcasts by any window in that channel will only be recevied by the other windows in that channel. The assignment of windows to channels would typically be managed by the user, through either a channel selector widget built into the window itself, or through a separate channel manager application.

All windows will initially be placed in the default channel, and will remain there unless they explicitly join another channel.

There are three types of channels: DefaultChannel, SystemChannel and AppChannel.

Index

Type aliases

Channel

Union of all possible concrete channel classes that may be returned by the service.

ChannelId

ChannelId: string

Type used to identify specific Channels. Though simply an alias of string, use of this type indicates use of the string as a channel identifier, and that the user should avoid assuming any internal structure and instead treat as a fully opaque object

Events

ChannelChangedEvent

ChannelChangedEvent:

Event fired whenever a window changes channel. See addEventListener.

This event can be used to track all channel changes, rather than listening only to a specific channel.

See also ChannelWindowAddedEvent/ChannelWindowRemovedEvent

channel

channel: Channel | null

The channel that the window now belongs to.

Will be null if the window has just been closed, and so is being removed from a channel without being added to another.

identity

identity: Identity

The window that has switched channel.

previousChannel

previousChannel: Channel | null

The previous channel that the window belonged to.

Will be null if the window has just been created, and so doesn't have a previous channel.

type

type: "channel-changed"

ChannelWindowAddedEvent

ChannelWindowAddedEvent:

Event fired when a window is added to a channel. See ChannelBase.addEventListener.

Note that this event will typically fire as part of a pair - since windows must always belong to a channel, a window can only join a channel by leaving its previous channel. The exceptions to this rule are when the window is created and destroyed when there will be no previous channel or no current channel, respectively.

To listen for channel changes across all (or multiple) channels, there is also a top-level ChannelChangedEvent.

channel

channel: Channel

The channel that window now belongs to. Will always be the channel object that ChannelBase.addEventListener was called on.

identity

identity: Identity

The window that has just been added to the channel.

previousChannel

previousChannel: Channel | null

The channel that the window belonged to previously.

Will be null if this event is being fired on a newly-created window.

type

type: "window-added"

ChannelWindowRemovedEvent

ChannelWindowRemovedEvent:

Event fired when a window is removed from a channel. See ChannelBase.addEventListener.

Note that this event will typically fire as part of a pair - since windows must always belong to a channel, a window can only join a channel by leaving it's previous channel. The exceptions to this rule are when the window is created and destroyed when there will be no previous channel or no current channel, respectively.

To listen for channel changes across all (or multiple) channels, there is also a top-level ChannelChangedEvent.

channel

channel: Channel | null

The channel that the window now belongs to.

Will be null if the window is leaving the channel due to it being closed.

identity

identity: Identity

The window that has just been removed from the channel.

previousChannel

previousChannel: Channel

The channel that the window belonged to previously. Will always be the channel object that ChannelBase.addEventListener was called on.

type

type: "window-removed"

Variables

Const defaultChannel

defaultChannel: DefaultChannel = new DefaultChannel()

The channel in which all windows will initially be placed.

All windows will belong to exactly one channel at all times. If they have not explicitly been placed into a channel via a ChannelBase.join call, they will be in this channel.

If an app wishes to leave any other channel, it can do so by (re-)joining this channel.

Functions

getChannelById

getCurrentChannel

  • getCurrentChannel(identity?: Identity): Promise<Channel>
  • Returns the channel that the current window is assigned to.

    throws

    If identity is passed, FDC3Error with an ConnectionError code.

    throws

    If identity is passed, TypeError if identity is not a valid Identity.

    Parameters

    • Optional identity: Identity

      The window to query. If omitted, will use the window that calls this method.

    Returns Promise<Channel>

getOrCreateAppChannel

  • getOrCreateAppChannel(name: string): Promise<AppChannel>
  • Returns an app channel with the given name. Either creates a new channel or returns an existing channel.

    It is up to your organization to decide how to share knowledge of these custom channels. As with organization defined contexts, app channel names should have a prefix specific to your organization to avoid name collisions, e.g. 'company-name.channel-name'.

    The service will assign a unique ID when creating a new app channel, but no particular mapping of name to ID should be assumed.

    throws

    TypeError if name is not a valid app channel name, i.e., a non-empty string.

    Parameters

    • name: string

      The name of the channel. Must not be an empty string.

    Returns Promise<AppChannel>

getSystemChannels

  • Gets all service-defined system channels.

    This is the list of channels that should be used to populate a channel selector. All channels returned will have additional metadata that can be used to populate a selector UI with a consistent cross-app channel list.

    Returns Promise<SystemChannel[]>