Recipes - FDC3

Standard recipes for FDC3 use cases.

Sharing context use case

On a user-selected event, broadcast a message from an app to other apps on the desktop.

Description

Context sharing is used to synchronize the user-selected state between multiple apps on the desktop. FDC3 context sharing is an open and permissive means of sharing data between all listening apps on a desktop. Since context can be in various forms from different sources, receivers should always inspect the type of information which is received before processing it.

Because context sharing is open by-design, payloads typically consist of identifiers (e.g. security tickers) instead of data. Due to the absence of a universal symbology for many financial entities, it is considered best practice for broadcasters and receivers to accommodate as many known identifiers as possible.

Sending an instrument context example

fdc3.broadcast({
    "type" : "fdc3.instrument",
    "name" : "Apple",
    "id" : 
    {  
        "ticker" : "aapl",
        "ISIN" : "US0378331005",
        "CUSIP" : "037833100",
        "FIGI" : "BBG000B9XRY4",
    }
});

Receiving an instrument context example

fdc3.addContextListener(ctx => {
    switch(ctx.type) {
        case "fdc3.instrument":
            updateSelectedInstrument(ctx.id);
        // other supported types...
    }
});

ViewChart: Raising a directed intent use case

A directed intent is used by one app to perform a certain action (ViewChart) in a known, different app.

Description

FDC3 intents enable workflows between apps, and unlike the context API, are centered around actions instead of data. In its simplest form, an intent is simply a point-to-point message consisting of a sender, which raises the intent, and a receiver which has registered the intent. When FDC3 is integrated with an app directory, it is also possible to raise an intent to an app which is not yet running.

Raising a ViewChart intent example

let result = await fdc3.raiseIntent("ViewChart", {
    type: "fdc3.instrument",
    name: "International Business Machines",
    id: {
        ticker: "ibm"
    }
}, "ACME Charting App");  // This is the intent recipient

Registering a ViewChart intent example

// for auto-launch capabilities, this intent should also be declared
// in the app directory entry for this app

fdc3.registerIntent("ViewChart", ctx => {
    showChartForInstrument(ctx.id);
});