Using JET API's publish and subscribe methods to communicate between two windows in the same app

mbarr
mbarr Explorer

I have an application that opens to a main window: Window 1. If you click a button in the app, a new window will open: Window 2.

From what I can tell, Window 1 and Window 2 do not share a JET component. E.g., if I store something in JET Archive in Window 1, then open Window 2, Window 2 won't be able to grab the item from JET Archive, because it has its own, empty JET Archive.

I would like to be able to communicate between the two windows. E.g., if I click on a button in Window 2, I want Window 1 to do something in response.

I know I can use JET Context Change to update linked Eikon windows by registering a RIC change. But is there a way to use publish and subscribe to communicate between Window 2 and Window 1?

Right now, I've got this code linked to a button in Window 2:

JET.publish('test', 'Test publish message');

And this code in Window 1:

JET.subscribe("test", this._publishCallBack);  

_publishCallBack: function(){
console.debug("inside publishCallBack, arguments = ", arguments);
}

But when I press the button in Window 2, nothing happens in the console in Window 1.

Have I set this up wrong? Or is what I have in mind just not possible?

Thanks for any help you can provide!

Best Answer

Answers