Provides access to the OpenFin representation of the current code context (usually a document
such as a View or Window), as well as to the current Interop
context.
Useful for debugging in the devtools console, where this will intelligently type itself based on the context in which the devtools panel was opened.
Publishes a message to all applications running on OpenFin Runtime that are subscribed to the specified topic.
The topic on which the message is sent
The message to be published. Can be either a primitive data type (string, number, or boolean) or composite data type (object, array) that is composed of other primitive or composite data types
fin.InterApplicationBus.publish('topic', 'hello').then(() => console.log('Published')).catch(err => console.log(err));
Sends a message to a specific application on a specific topic.
The identity of the application to which the message is sent
Optional
name?: stringThe topic on which the message is sent
The message to be sent. Can be either a primitive data type (string, number, or boolean) or composite data type (object, array) that is composed of other primitive or composite data types
fin.InterApplicationBus.send(fin.me, 'topic', 'Hello there!').then(() => console.log('Message sent')).catch(err => console.log(err));
Subscribes to messages from the specified application on the specified topic.
This object is described in the Identity in the typedef
Optional
name?: stringThe topic on which the message is sent
A function that is called when a message has been received. It is passed the message, uuid and name of the sending application. The message can be either a primitive data type (string, number, or boolean) or composite data type (object, array) that is composed of other primitive or composite data types
// subscribe to a specified application
fin.InterApplicationBus.subscribe(fin.me, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
// subscribe to wildcard
fin.InterApplicationBus.subscribe({ uuid: '*' }, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to *')).catch(err => console.log(err));
Unsubscribes to messages from the specified application on the specified topic.
This object is described in the Identity in the typedef
Optional
name?: stringThe topic on which the message is sent
A callback previously registered with subscribe()
If you are listening to all apps on a topic, (i.e you passed { uuid:'*' }
to the subscribe function)
then you need to pass { uuid:'*' }
to unsubscribe as well. If you are listening to a specific application,
(i.e you passed { uuid:'some_app' }
to the subscribe function) then you need to provide the same identifier to
unsubscribe, unsubscribing to *
on that same topic will not unhook your initial listener otherwise.
const listener = console.log;
// If any application publishes a message on topic `foo`, our listener will be called.
await fin.InterApplicationBus.subscribe({ uuid:'*' }, 'foo', listener)
// When you want to unsubscribe, you need to specify the uuid of the app you'd like to
// unsubscribe from (or `*`) and provide the same function you gave the subscribe function
await fin.InterApplicationBus.unsubscribe({ uuid:'*' }, 'foo', listener)
A messaging bus that allows for pub/sub messaging between different applications.