Tutorial: fdc3v2.raiseIntent

fdc3v2.raiseIntent

Raises a specific intent. It returns a Promise that resolves with an IntentResolution.

When specifying a target app, this will be added as metadata to the intent. It can then be accessed by the app provider using InteropBroker.handleFiredIntent.

Example

tickerElement.on('click', async (element) => {
    const ticker = element.innerText;
    const context = { type: 'fdc3.instrument', id: { ticker } };

    const intentResolution = await fdc3.raiseIntent('ViewChart', context);
})

// Passing in a target app
tickerElement.on('click', async (element) => {
    const ticker = element.innerText;
    const context = { type: 'fdc3.instrument', id: { ticker } };

    const intentResolution = await fdc3.raiseIntent('ViewChart', context, 'skype');
})

For FDC3 2.0 the IntentResolution will look like this:

{
    source: {
        appId: 'openfin-app',
        instanceId: 'R56Y12N0567'
    },
    intent: string,
    version: '2.0',
    getResult: (): Promise<IntentResult> => {}
}

When calling getResult, if the application that is intended to handle the Intent has not setup an IntentHandler yet, the Promise will stay pending. Whenever the the IntentHandler returns the IntentResult Promise will resolve.