-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New channel proposition #171
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
099930e
updated spec with more detailed explanation of the 'default' channel
nkolba a72585a
some more clarifications for the 'default' channel
nkolba 12142f7
first pass
nkolba f190362
fixed example syntax
nkolba e793d25
missed 'default' reference
nkolba ba3afdf
more tweaks for the global channel
nkolba b4d4b94
fixes from PR feedback. Cleaned example code. Return promise on lea…
nkolba 6d6999a
add await to example
nkolba 3f8e09d
spacing
nkolba 4c21494
merge from upstream
nkolba 2c5c753
clarified language for 'global' channel example
nkolba ff3cde4
updated 'global' example
nkolba 87d9473
added missing methods to ts block, added a context section in block
nkolba File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,18 +142,50 @@ Context channels allows a set of apps to share a stateful piece of data between | |
|
||
There are two types of channels, which are functionally identical, but have different visibility and discoverability semantics. | ||
|
||
1. The 'system' ones, which have a well understood identity. One is called 'default'. | ||
1. The 'system' ones, which have a well understood identity. One is called 'global'. | ||
2. The 'app' ones, which have a transient identity and need to be revealed | ||
|
||
The 'system' channels include a 'default' channel which serves as the backwards compatible layer with the 'send/broadcast context' above. There are some reserved channel names for future use. Currently this is just 'global'. | ||
|
||
|
||
### Joining Channels | ||
Apps can join channels. An app can only be joined to one channel at a time. When an app joins a channel it will automatically recieve the current context for that channel, except if the channel joined is the 'default'. | ||
Apps can join channels. An app can only be joined to one channel at a time. When an app joins a channel it will automatically recieve the current context for that channel. | ||
|
||
When an app is joined to a channel, calls to fdc3.broadcast and listeners added through fdc3.addContextListener will be routed to that channel. If an app is not explicitly joined to a channel, it is on the 'default' channel. It is up to the desktop agent to determine the behavior of the 'default' channel, and if context is automaticaly broadcast over it or not. | ||
When an app is joined to a channel, calls to fdc3.broadcast and listeners added through fdc3.addContextListener will be routed to that channel. If an app is not joined to a channel these methods will be no-ops, but apps can still choose to listen and broadcast to specific channels via the methods on the `Channel` class. | ||
|
||
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. | ||
|
||
### The 'global' Channel | ||
The 'system' channels include a 'global' channel which serves as the backwards compatible layer with the 'send/broadcast context' behavior in FDC3 1.0. A desktop agent MAY choose to make membership in the 'global' channel the default state for apps on start up. | ||
|
||
The 'global' channel should be returned as part of the response from the `fdc3.getSystemChannels` call. Desktop Agents may want to filter out the 'global' option in their UI for system channel pickers. | ||
|
||
|
||
#### Examples | ||
|
||
An app queries the current context of the `global` channel. | ||
|
||
```js | ||
const globalChannel = await fdc3.getOrCreateChannel("global"); | ||
const context = await globalChannel.getCurrentContext("fdc3.instrument"); | ||
``` | ||
|
||
An app can explicitly receive context events on the `global` (or any other) channel, regardless of what it is currently joined to. | ||
|
||
```js | ||
// retrieve current fdc3 context | ||
const context = await fdc3.getCurrentContext("fdc3.instrument") | ||
// context is null, as not currently joined to a channel | ||
|
||
const globalChannel = await fdc3.getSystemChannels.filter(c => c.id === "global") | ||
const globalContext = await fdc3.getCurrentContext("fdc3.instrument") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want |
||
// context is instrument AAPL on the global channel | ||
|
||
fdc3.joinChannel('global') | ||
const context = await fdc3.getCurrentContext('fdc3.instrument') | ||
// top-level context is now instrument AAPL as well because we have joined the global channel | ||
``` | ||
|
||
### Direct Listening and Broadcast on Channels | ||
While joining channels automates a lot of the channel behavior for an app, it has the limitation in that an app can belong to only one channel at a time. Listening and Broadcasting to channels using the _Channel.addBroadcastListener_ and the _Channel.broadcast_ APIs provides an app with fine-grained controls for specific channels. This is especially useful for working with dynamic _App Channels_. | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is main reason to have this
getSystemChannels.filter
example here in addition togetOrCreateChannel
example above?Should you even have to do the
filter
thing with explicit API to get a channel?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the APIs,
getSystemChannels
returns an array of the well-known system channels, e.g. red, global etc.If it is a system channel, it is just a different way to get the same channel. I just did this to show the alternative.