cancel
Showing results for 
Search instead for 
Did you mean: 

Global JS Object in Launchpad

Former Member
0 Kudos

Hello everyone,

in our company we started to deploy some fiori apps into the launchpad. Now we want these apps to share some data and functionality via a global Javascript Object inside the Launchpad. What is the best way to achieve that? Maybe via modules?

We tried it so far the "normal" JS-way: window.myGlobal = ... in the Component.js - file on one of the apps. But the first problem is, the file is only executed, if the app gets started and the second problem is that we can't access the variable in another app. It is undefined, although all apps share the same window object: .

All ideas are welcome.

Thanks in advance,

Silvio.

Edit: I found out so far, that the apps are executed inside an iframe and so they do not share the same window object.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos


Hi Silvio,

The recommended way to communicate between components/apps is via the eventbus, general best practices in js is to avoid global variables as they become increasingly tough to maintain as your application grows.

Please find more info on eventbus

Step 3: Navigation and Routing

Thank you.

Regards,

               Pruthvi.

Former Member
0 Kudos

Hello Pruthvi,

you're absolutly right in general. But in our scenario it is necessary that the apps share data on client side, because sometimes the state of one app depends on the state of another app.

The solution in our case was to deploy the app as components, not as standalone apps inside launchpad via the index.html. The problem is, although Component.js and index.html share the same folder at development time they are in different folders on runtime. So we had to find the right path. It is a bit confusing, but here the concret example:

Works: <host:port>/sap/bc/bsp/sap/myapp/index.html

Works NOT: <host:port>/sap/bc/bsp/sap/myapp/Component.js

Works: <host:port>/sap/bc/ui5_ui5/sap/myapp/Component.js


So now the app no longer running as iframes inside the launchpad and share the same window object.


Problem solved.


Greetings,


Silvio.

Answers (0)