AppChannel

Custom application-created channels.

Applications can create these for specialised use-cases. These channels should be obtained by name by calling getOrCreateAppChannel and it is up to your organization to decide how applications are aware of this name. 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'.

App channels can be joined by any window, but are only indirectly discoverable if the name is not known.

Hierarchy

Index

Properties

id

Constant that uniquely identifies this channel. Will be generated by the service, and guaranteed to be unique within the set of channels registered with the service.

In the case of system channels (see SystemChannel), these IDs should persist across sessions. The channel list is defined by the service, but can be overridden by a desktop owner. If the desktop owner keeps this list static (which is recommended), then IDs will also persist across sessions.

name

name: string

The name of this channel. This is the same string as is passed to getOrCreateAppChannel.

type

type: "app"

Methods

addContextListener

addEventListener

  • addEventListener(eventType: "window-added", handler: function): void
  • addEventListener(eventType: "window-removed", handler: function): void
  • Event that is fired whenever a window joins this channel. This includes switching to/from the default channel.

    The event also includes which channel the window was in previously. The channel property within the event will always be this channel instance.

    Parameters

    Returns void

  • Event that is fired whenever a window leaves this channel. This includes switching to/from the default channel.

    The event also includes which channel the window is being added to. The previousChannel property within the event will always be this channel instance.

    Parameters

    Returns void

broadcast

  • broadcast(context: Context): Promise<void>
  • Broadcasts the given context on this channel.

    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.

    This broadcast will be received by all windows that are members of this channel, except for the window that makes the broadcast. This matches the behavior of the top-level FDC3 broadcast function.

    throws

    TypeError if context is not a valid Context.

    Parameters

    • context: Context

      The context to broadcast to all windows on this channel.

    Returns Promise<void>

getCurrentContext

  • getCurrentContext(): Promise<Context | null>
  • Returns the last context that was broadcast on this channel. All channels initially have no context, until a window is added to the channel and then broadcasts. If there is not yet any context on the channel, this method will return null. The context is also reset back into its initial context-less state whenever a channel is cleared of all windows.

    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.

    NOTE: Only non-default channels are stateful, for the default channel this method will always return null.

    Returns Promise<Context | null>

getMembers

  • getMembers(): Promise<Identity[]>
  • Returns a list of all windows belonging to the specified channel.

    If the window making the call is a member of this channel, it will be included in the results. If there are no windows on this channel, an empty array is returned.

    Returns Promise<Identity[]>

join

  • join(identity?: Identity): Promise<void>
  • Adds the given window to this channel. If no identity is provided, the window making the call will be the window added to the channel.

    If the channel has a current context (see getCurrentContext) then that context will be immediately passed to the given window upon joining the channel, via its context listener(s).

    Note that all windows will always belong to exactly one channel at all times. If you wish to leave a channel, the only way to do so is to join another channel. A window may rejoin the default channel by calling channels.defaultChannel.join().

    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 that should be added to this channel. If omitted, will use the window that calls this method.

    Returns Promise<void>

removeEventListener

  • removeEventListener(eventType: "window-added", handler: function): void
  • removeEventListener(eventType: "window-removed", handler: function): void