Using JET API's publish and subscribe methods to communicate between two windows in the same app
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
-
This is the standard app dialog.
0
Answers
-
Hi @mbarr, can you try this code that I have?
JET.subscribe("/jetplayground", function(message, channel) {
console.log("From Channel: '"+channel+"' Data: "+message);
});
JET.publish("/jetplayground", "From PUB app");Above code is working on my side.
0 -
Hi Panit.
I copied your code exactly, but it still is not working.
When you say it is working on your side, are you running the first line in window 1 of an app and then second line in window 2 generated from window 1?
0 -
They are in the separate window but should also working on the same window as well. The next thing to check is what's the URL you're running this page. Is it localhost? This API is only working with localhost or white-listed domain.
0 -
They are in the separate window but should also working on the same window as well. The next thing to check is what's the URL you're running this page. Is it localhost? This API is only working with localhost or white-listed domain.
0 -
I am running this on what should be white-listed urls. The app is otherwise able to use JET API just fine, and the app has been on the TR/Eikon store for months now.
0 -
Can you try the same code in localhost? There's also a JET test page at cpurl://apps.cp./apps/jetplayground
You can try this API in the app, choose Publish/Subsribe sample from the catalog. If it's working in jetplayground but not working on yours, I'm quite sure that it's blocked by the URL.
0 -
When i run the Publish/Subscribe sample, I have two windows, but the message from the pub app is not showing up in the sub app. It's behaving just like what I was trying in my app. The published message is not getting picked up by the subscriber. Could the exact version of JET API be a factor?
0 -
Did you click "Run" at the subscribe window as well?
0 -
I added an image in an answer below. Yes, I clicked run in both windows.
0 -
Can you try to put cpurl://apps.cp./apps/jetplayground in the main search box? You seems to be running it from the 3rd party container. If it's working in the standard window (popup from entering the url from the seach box), it means this API is limited to only TR applications.
0 -
Yeah, I never see the "From Channel" messages in the subscriber window. Even after I click Run and wait 3+ seconds.
0 -
Can you try to put cpurl://apps.cp./apps/jetplayground in the main search box? You seems to be running it from the 3rd party container. If it's working in the standard window (popup from entering the url from the seach box), it means this API is limited to only TR applications.
0 -
Ah! Yes, it is working when I run it out of the main search box, but not out of the Dev one. Does this mean our 3rd party app won't be able to use Publish/Subscribe? Or just I won't be able to test it in the Dev environment?
0 -
I'll ask the owner of 3rd party container to confirm on this thread on Monday. It's likely to me that this API is limited to only TR app.
0 -
Great! Appreciate all your efforts on this and the quick, thorough replies. Have a good weekend!
0 -
Great! Appreciate all your efforts on this and the quick, thorough replies. Have a good weekend!
0 -
Just wanted to make sure that the pub-sub API is limited to only the TR app. If not, would love to be able to make use of it in our app.
0 -
Any word on whether pub-sub is usable outside the TR app?
0 -
Sorry for delay response. I've just got the confirmation from the container team that only localhost or whitelisted urls are allowed. So that means the url you're using is not whitelisted. If you let me know the url, I can do the checking.
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛