Skip to main content

Interface: Channel

types.FDC3.Channel

Object representing a context channel.

Properties

displayMetadata

Optional Readonly displayMetadata: DisplayMetadata

Channels may be visualized and selectable by users. DisplayMetadata may be used to provide hints on how to see them. For app channels, displayMetadata would typically not be present


id

Readonly id: string

Constant that uniquely identifies this channel.


type

Readonly type: string

Uniquely defines each channel type.

Methods

addContextListener

addContextListener(handler): Listener

Adds a listener for incoming contexts whenever a broadcast happens on this channel.

deprecated use addContextListener(null, handler) instead of addContextListener(handler).

Parameters

NameType
handlerContextHandler

Returns

Listener

addContextListener(contextType, handler): Listener

Adds a listener for incoming contexts of the specified context type whenever a broadcast happens on this channel.

Parameters

NameType
contextTypenull | string
handlerContextHandler

Returns

Listener


broadcast

broadcast(context): void

Broadcasts the given context on this channel. This is equivalent to joining the channel and then calling the top-level FDC3 broadcast function.

Note that this function can be used without first joining the channel, allowing applications to broadcast on channels that they aren't a member of.

Channel implementations should ensure that context messages broadcast by an application on a channel should not be delivered back to that same application if they are joined to the channel.

Error with a string from the ChannelError enumeration.

Parameters

NameType
contextContext

Returns

void


getCurrentContext

getCurrentContext(contextType?): Promise<null | Context>

Returns the last context that was broadcast on this channel. All channels initially have no context, until a context is broadcast on the channel. If there is not yet any context on the channel, this method will return null.

The context of a channel will be captured regardless of how the context is broadcasted on this channel - whether using the top-level FDC3 broadcast function, or using the channel-level broadcast function on this object.

Optionally a contextType can be provided, in which case the current context of the matching type will be returned (if any). Desktop agent implementations may decide to record contexts by type, in which case it will be possible to get the most recent context of the type specified, but this is not guaranteed.

Error with a string from the ChannelError enumeration.

Parameters

NameType
contextType?string

Returns

Promise<null | Context>