Skip to content

Commit

Permalink
Merge pull request #512 from ChartIQ/431-make-joinChannel-leaveCurren…
Browse files Browse the repository at this point in the history
…tChannel-optional

431 Making joinChannel, leaveCurrentChannel and getCurrentChannel functions optional
  • Loading branch information
Kris West authored Feb 4, 2022
2 parents e042101 + 85c9f9e commit 04d2064
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* Updated copyright notices ([#467](https://github.com/finos/FDC3/pull/467))
* Adjusted wording in API spec and documentation to acknowledge the possibility of methods of intent resolution other than a resolver UI ([#461](https://github.com/finos/FDC3/pull/461))
* Moved the Icon type definition into the Types documentation page for consistency with other types. ([#493](https://github.com/finos/FDC3/pull/493)
* The `fdc3.joinChannel()`, `fdc3.getCurrentChannel()` and `fdc3.leaveCurrentChannel()` functions have been made optional for FDC3 API compliance, but are recommended through the application of the SHOULD keyword. ([#512](https://github.com/finos/FDC3/pull/512))
* All DesktopAgent and Channel API functions are now async for consistency, changing the return type of the `broadcast`, `addIntentListener`, `addContextListener` and `getInfo` functions ([#516](https://github.com/finos/FDC3/pull/516))

### Deprecated
Expand Down
11 changes: 8 additions & 3 deletions docs/api/ref/DesktopAgent.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface DesktopAgent {
// channels
getOrCreateChannel(channelId: string): Promise<Channel>;
getSystemChannels(): Promise<Array<Channel>>;
// optional channel management functions
joinChannel(channelId: string) : Promise<void>;
getCurrentChannel() : Promise<Channel | null>;
leaveCurrentChannel() : Promise<void>;
Expand Down Expand Up @@ -250,7 +251,9 @@ A promise resolving to all the intents, their metadata and metadata about the ap
getCurrentChannel() : Promise<Channel | null>;
```

Returns the `Channel` object for the current channel membership. Returns `null` if the app is not joined to a channel.
Optional function that returns the `Channel` object for the current channel membership. In most cases, an application's membership of channels SHOULD be managed via UX provided to the application by the desktop agent, rather than calling this function directly.

Returns `null` if the app is not joined to a channel.


#### Examples
Expand Down Expand Up @@ -338,7 +341,8 @@ const redChannel = systemChannels.find(c => c.id === 'red');
joinChannel(channelId: string) : Promise<void>;
```

Joins the app to the specified channel.
Optional function that joins the app to the specified channel. In most cases, applications SHOULD be joined to channels via UX provided to the application by the desktop agent, rather than calling this function directly.

If an app is joined to a channel, all `fdc3.broadcast` calls will go to the channel, and all listeners assigned via `fdc3.addContextListener` will listen on the channel.

If the channel already contains context that would be passed to context listeners added via `fdc3.addContextListener` then those listeners will be called immediately with that context.
Expand Down Expand Up @@ -370,8 +374,9 @@ fdc3.joinChannel(selectedChannel.id);
leaveCurrentChannel() : Promise<void>;
```

Removes the app from any channel membership. Context broadcast and listening through the top-level `fdc3.broadcast` and `fdc3.addContextListener` will be a no-op when the app is not joined to a channel.
Optional function that removes the app from any channel membership. In most cases, an application's membership of channels SHOULD be managed via UX provided to the application by the desktop agent, rather than calling this function directly.

Context broadcast and listening through the top-level `fdc3.broadcast` and `fdc3.addContextListener` will be a no-op when the app is not joined to a channel.

#### Examples

Expand Down
4 changes: 3 additions & 1 deletion docs/api/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ When an app joins a channel, or adds a context listener when already joined to a

It is possible that a call to join a channel could be rejected. If for example, the desktop agent wanted to implement controls around what data apps can access.

Joining channels in FDC3 is intended to be a behavior initiated by the end user. For example: by color linking or apps being grouped in the same workspace. Most of the time, it is expected that apps will be joined to a channel by mechanisms outside of the app. Always, there SHOULD be a clear UX indicator of what channel an app is joined to.
Joining channels in FDC3 is intended to be a behavior initiated by the end user. For example: by color linking or apps being grouped in the same workspace. Most of the time, it is expected that apps will be joined to a channel by mechanisms outside of the app. To support programmatic management of joined channels and the implementation of channel selector UIs other than those provided outside of the app, Desktop Agent implementations MAY provide [`fdc3.joinChannel()`](ref/DesktopAgent#joinchannel), [`fdc3.getCurrentChannel()](ref/DesktopAgent#getcurrentchannel) and [`fdc3.leaveCurrentChannel()`](ref/DesktopAgent#leavecurrentchannel) functions and if they do, MUST do so as defined in the [Desktop Agent API reference](ref/DesktopAgent).

There SHOULD always be a clear UX indicator of what channel an app is joined to.

#### Examples

Expand Down
9 changes: 6 additions & 3 deletions src/api/DesktopAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ export interface DesktopAgent {
getSystemChannels(): Promise<Array<Channel>>;

/**
* Joins the app to the specified channel.
* Optional function that joins the app to the specified channel. In most cases, applications SHOULD be joined to channels via UX provided to the application by the desktop agent, rather than calling this function directly.
*
* If an app is joined to a channel, all `fdc3.broadcast` calls will go to the channel, and all listeners assigned via `fdc3.addContextListener` will listen on the channel.
* If the channel already contains context that would be passed to context listeners assed via `fdc3.addContextListener` then those listeners will be called immediately with that context.
* An app can only be joined to one channel at a time.
Expand All @@ -268,13 +269,15 @@ export interface DesktopAgent {
getOrCreateChannel(channelId: string): Promise<Channel>;

/**
* Returns the `Channel` object for the current channel membership.
* Optional function that returns the `Channel` object for the current channel membership. In most cases, an application's membership of channels SHOULD be managed via UX provided to the application by the desktop agent, rather than calling this function directly.
*
* Returns `null` if the app is not joined to a channel.
*/
getCurrentChannel(): Promise<Channel | null>;

/**
* Removes the app from any channel membership.
* Optional function that removes the app from any channel membership. In most cases, an application's membership of channels SHOULD be managed via UX provided to the application by the desktop agent, rather than calling this function directly.
*
* Context broadcast and listening through the top-level `fdc3.broadcast` and `fdc3.addContextListener` will be a no-op when the app is not on a channel.
* ```javascript
* //desktop-agent scope context listener
Expand Down

0 comments on commit 04d2064

Please sign in to comment.