Skip to content

Commit dbabd3b

Browse files
committed
feat(spec): add deprecation notices to API spec
- deprecation of 'global' channel - deprecation of IntentResolution.data property Relates to #326
1 parent 1f70177 commit dbabd3b

File tree

1 file changed

+35
-15
lines changed

1 file changed

+35
-15
lines changed

docs/api/spec.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function fdc3Stuff() {
4747
if (window.fdc3) {
4848
fdc3Stuff();
4949
} else {
50-
window.addEventListener("fdc3Ready", fdc3Stuff);
50+
window.addEventListener('fdc3Ready', fdc3Stuff);
5151
}
5252
```
5353

@@ -115,6 +115,15 @@ Raising an Intent will return a Promise-type object that will resolve/reject bas
115115
- The intent was ambiguous and the resolver experienced an error.
116116

117117
##### Resolution Object
118+
119+
> **Deprecation notice**
120+
>
121+
> It is not currently possible to provide a value for the `data` property described below,
122+
as intent listeners don't currently offer a way to return values.
123+
>
124+
> Future versions of FDC3 plan to remove the optional `data` property from the intent resolution object,
125+
and include a more robust mechanism for intents that need to return data back to the caller.
126+
118127
If the raising of the intent resolves (or rejects), a standard object will be passed into the resolver function with the following format:
119128

120129
```js
@@ -128,14 +137,12 @@ If the raising of the intent resolves (or rejects), a standard object will be pa
128137
- *data* = return data structure - if one is provided for the given intent
129138
- *version* = the version number of the Intents schema being used
130139

140+
131141
For example, to raise a specific Intent:
132142

133143
```js
134144
try {
135145
const result = await fdc3.raiseIntent('StageOrder');
136-
if (result.data) {
137-
const orderId = result.data.id;
138-
}
139146
}
140147
catch (er){
141148
console.log(er.message);
@@ -185,10 +192,10 @@ From version 1.2 of the FDC3 specification, it is possible to retrieve informati
185192
```js
186193
import {compareVersionNumbers, versionIsAtLeast} from '@finos/fdc3';
187194

188-
if (fdc3.getInfo && versionIsAtLeast(fdc3.getInfo(), "1.2")) {
195+
if (fdc3.getInfo && versionIsAtLeast(fdc3.getInfo(), '1.2')) {
189196
await fdc3.raiseIntentForContext(context);
190197
} else {
191-
await fdc3.raiseIntent("ViewChart", context);
198+
await fdc3.raiseIntent('ViewChart', context);
192199
}
193200
```
194201

@@ -202,6 +209,9 @@ Context channels allows a set of apps to share a stateful piece of data between
202209
There are two types of channels, which are functionally identical, but have different visibility and discoverability semantics.
203210

204211
1. The 'system' ones, which have a well understood identity. One is called 'global'.
212+
213+
> **Deprecation notice:** In future versions of FDC3, there won't be a `global` channel, see [below](#the-global-channel).
214+
205215
2. The 'app' ones, which have a transient identity and need to be revealed
206216

207217

@@ -215,34 +225,44 @@ It is possible that a call to join a channel could be rejected. If for example,
215225
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.
216226

217227
### The 'global' Channel
228+
229+
> **Deprecation notice**
230+
>
231+
> The global channel, which exists only for backward compatibility with FDC3 1.0,
232+
will be removed in a future version of the FDC3 API Specification.
233+
>
234+
> Instead of relying on being joined to a 'default' channel by the desktop agent on startup,
235+
an app or system channel should be joined explicitly through the relevant APIs,
236+
or through a channel selection UI.
237+
218238
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.
219239

220240
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.
221241

222242

223243
#### Examples
224244

225-
An app queries the current context of the `global` channel.
245+
An app queries the current context of the `red` channel.
226246

227247
```js
228-
const globalChannel = await fdc3.getOrCreateChannel("global");
229-
const context = await globalChannel.getCurrentContext("fdc3.instrument");
248+
const redChannel = await fdc3.getOrCreateChannel('red');
249+
const context = await redChannel.getCurrentContext('fdc3.instrument');
230250
```
231251

232-
An app can explicitly receive context events on the `global` (or any other) channel, regardless of what it is currently joined to.
252+
An app can still explicitly receive context events on any channel, regardless of the channel it is currently joined to.
233253

234254
```js
235255
// check for current fdc3 channel
236256
let joinedChannel = await fdc3.getCurrentChannel()
237257
//current channel is null, as the app is not currently joined to a channel
238258

239-
const globalChannel = await fdc3.getSystemChannels.filter(c => c.id === "global")
240-
const globalContext = await globalChannel.getCurrentContext("fdc3.instrument")
259+
const redChannel = await fdc3.getSystemChannels.filter(c => c.id === 'red')
260+
const context = await redChannel.getCurrentContext('fdc3.instrument')
241261
// context is instrument AAPL on the global channel
242262

243-
fdc3.joinChannel('global')
263+
fdc3.joinChannel('blue')
244264
joinedChannel = await fdc3.getCurrentChannel()
245-
//current channel is now the 'global' channel
265+
//current channel is now the 'blue' channel
246266

247267
```
248268

@@ -280,7 +300,7 @@ const appChannel = await fdc3.getOrCreateChannel('my_custom_channel');
280300
// get the current context of the channel
281301
const current = await appChannel.getCurrentContext();
282302
// add a listener
283-
appChannel.addContextListener(context => {...});
303+
appChannel.addContextListener('my_context_type', context => {...});
284304
// broadcast to the channel
285305
appChannel.broadcast(context);
286306

0 commit comments

Comments
 (0)