Add signals with context sharing
To support the Signals feature of the Here™ enterprise browser, you implement context sharing.
If your web apps already support FDC3 or the OpenFin interoperability APIs, they automatically work to provide context sharing across tabs in a supertab.
Otherwise, you can add context sharing to your web apps to enable users to share data with other apps.
In the simplest of terms, context sharing is like copying and pasting or entering the same information in all applications at the same time. For example, a call center agent could work with applications for Customer Account Details, Customer History, and Current Orders open in a supertab. All these applications show data for a specific Customer. In this case, Customer is the context and a change of Customer in one application will update all the other applications.
A context or context object is a structured description of something. A good practice is to include as many data fields as possible in your context objects. This lets different applications share data effectively when their underlying datasets differ. In the Customer example, it's a good idea for the Customer context to contain not just an ID, but also email, name, and phone number. If the Customer History app relies on customers' emails to identify customers, but the Current Orders app relies on customer IDs, the two apps can share data because the context object includes both items.
How context sharing works
Here™ requires an app to register a handler for all or specific context types. The handler is then called when a new context is set for the supertab so that the app can be updated with the data specified by the context object. If the app has no handler for a context type, it does not receive updates for that type.
Receive contexts
In your application’s code, define a listener using fin.me.interop.addContextHandler:
import { fin } from '@openfin/core'
function handleOrganizationContext(contextInfo) {
const { type, id } = contextInfo;
console.log('contextInfo for organization:', contextInfo)
}
function handleCountryContext(contextInfo) {
const { type, id } = contextInfo;
console.log('contextInfo for country:', contextInfo)
}
fin.me.interop.addContextHandler(handleOrganizationContext, 'organization')
fin.me.interop.addContextHandler(handleCountryContext, 'country')
Send a context
To change the context, an application creates a context object and calls a function to set it.
In your application's code, define an emitter using fin.me.interop.setContext:
setCountryContext = async (name) => {
fin.me.interop.setContext({
type: 'country',
id: { name }
});
}
// The end-user selects a country of interest.
// The application sets that country Context informing other applications within the supertab.
element.on('click', (evt) => {
setCountryContext(evt.name)
})
FDC3
Here™ fully supports the FDC3 standard. The default configuration implements version 2.0 of the FDC3 standard.
If your app relies on financial data or supports financial use cases, we recommend that you work with the standard FDC3 context objects.
Further reading
For how context sharing works in the underlying APIs, see the Interoperability overview in the OpenFin developer guide.