Both the IntentListener and ContextListener allow you to subscribe to events raised by the Desktop Agent. However, neither of them have a mechanism for removing this subscription.
Also, their relationships with the Desktop Agent is a little hidden, I'm guessing that they access some global agent instance in order to register themselves? This has a couple of issues:
It relies on a singleton Desktop Agent
The relationship between agent / listener isn't explicit - which can give rise to memory leaks.
I'd prefer to see a more explicit subscribe / unsubscribe:
For example:
const viewChartListener = fdc3.addIntentListener("ViewChart", (context) => {
// do something meaningful here ...
console.log("intent event occurred with context", context);
});
// .. at some point in the future ..
viewChartListener.unsubscribe();
Both the
IntentListener
andContextListener
allow you to subscribe to events raised by the Desktop Agent. However, neither of them have a mechanism for removing this subscription.Also, their relationships with the Desktop Agent is a little hidden, I'm guessing that they access some global agent instance in order to register themselves? This has a couple of issues:
I'd prefer to see a more explicit subscribe / unsubscribe:
For example: