The Channel namespace allows an OpenFin application to create a channel as a ChannelProvider,
or connect to a channel as a ChannelClient. The "handshake" between the communication partners is
simplified when using a channel. A request to connect to a channel as a client will return a promise that resolves if/when the channel has been created. Both the
provider and client can dispatch actions that have been registered on their opposites, and dispatch returns a promise that resolves with a payload from the other
communication participant. There can be only one provider per channel, but many clients. Version 9.61.35.*
or later is required for both communication partners.
Asynchronous Methods
Methods
(static) connect(channelName, options) → {Promise.<Channel#ChannelClient>}
Connect to a channel. Returns a promise for a ChannelClient instance for that channel. If you wish to send a payload to the provider, add a payload property to the options argument.
Parameters:
Name | Type | Description |
---|---|---|
channelName |
string | Name of the target channel. |
options |
InterApplicationBus.Channel~ConnectOptions | Connection options. |
- Tutorials:
Returns:
Returns promise that resolves with an instance of ChannelClient.
- Type
- Promise.<Channel#ChannelClient>
(static) create(channelName) → {Promise.<Channel#ChannelProvider>}
Create a new channel. Returns a promise that resolves with a ChannelProvider instance for your channel. You must provide a unique channelName. If a channelName is not provided, or it is not unique, the creation will fail.
Parameters:
Name | Type | Description |
---|---|---|
channelName |
string | Name of the channel to be created. |
- Tutorials:
Returns:
Returns promise that resolves with an instance of ChannelProvider.
- Type
- Promise.<Channel#ChannelProvider>
(static) onChannelConnect(listener) → {Promise.<void>}
Listens for channel connections.
Parameters:
Name | Type | Description |
---|---|---|
listener |
InterApplicationBus.Channel~ConnectionEvent | callback to execute. |
- Tutorials:
Returns:
- Type
- Promise.<void>
(static) onChannelDisconnect(listener) → {Promise.<void>}
Listen for channel disconnections.
Parameters:
Name | Type | Description |
---|---|---|
listener |
InterApplicationBus.Channel~ConnectionEvent | callback to execute. |
- Tutorials:
Returns:
- Type
- Promise.<void>
Type Definitions
ConnectionEvent
Callback for onChannelConnect or onChannelDisconnect.
Type:
- object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
channelId |
string | Identifier of the channel. |
|
uuid |
string | Channel provider uuid. |
|
name |
string |
<optional> |
Channel provider name. |
channelName |
string | Name of the channel. |
ConnectOptions
Options provided on a client connection to a channel.
Type:
- object
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
payload |
any |
<optional> |
Payload to pass to ChannelProvider onConnection action. |
|
wait |
boolean |
<optional> |
true | If true will wait for ChannelProvider to connect. If false will fail if ChannelProvider is not found. |