Description
There a couple of alterations that I'd suggest making to the API following my attempts at implementing it within our setup and how we expect it will actually get used
-
Can the default channel be be hidden behind a
getter
that returns a promise. That would make it's use consistent with thegetOrCreate
andgetSystemChannels
. -
Could we modify the
addBroadcastListener
to take an optional array of context types. Then the interop broker would only notify the listener in the event of one of those specified types being transmitted.
This gives the following advantages
- As it's possible to put anything on a channel, receiving applications will all have to put in their place their own filtering mechanisms to only receive the items that they
- Allows applications to put different context types onto a channel that can be picked up by different consuming applications. For example, two different instruments can be transmitted by app and treated in different ways by a number of different receiving apps - some may want both, some one, some the other.
There is a downside here in that the channel will need to keep a history of the last received item by type, instead of just the last item - but that would just be a case of holding them within a map
-
Following on from 2, we would then need to add the same context type to the
getCurrentContext
method -
In context of a requirement that we have with regards to window based channel selectors, and following on from https://github.com/FDC3/FDC3/issues/118 I would propose the following approach to managing window selectors
On the channels module in https://github.com/FDC3/FDC3/blob/master/src/api/channel/channel.ts
add a function something along the lines of
public addWindowChannelListener(listener: (event: {channel: Channel; context: Context}) => void, types: string[]): DesktopAgent.Listener;
Then the application does not need to know about or worry about the action of selecting a channel. The swapping between channels can be handled within the broker/router code.
If the user sets the channel to "off" then the application just doesn't receive anything
A DesktopAgent.Listener
is returned should the application decide that it wishes explicitly stop receiving anything regardless.