Tutorial: InterApplicationBus.unsubscribe

InterApplicationBus.unsubscribe

Unsubscribes to messages from the specified application on the specified topic.

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.

Example

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)