Share a Client Variable between apps
Collaborate with us
Edit this page on GitHub
This document shows how you can share some value between two apps using Client Variables. We're using a Block to share the value, but you can do the same with a public Client Action. The instructions apply to Reactive Web and Mobile App.
Create the first app and a Client Variable
Follow these steps to create a Client Variable and initialize its value when the module loads.
- Create a sample Reactive Web App, name it ReactiveAppA, and add a Web Module to it. When the editor opens, add a Screen to the app.
- Go to the Data tab > right-click Client Variables > select Add Client Variable. Name the variable MyClientVariable.
- Go to the Logic tab > right-click Client Actions > select Add System Event > select On Application Ready.
- Drag an Assign Tool to the Flow and assign
Client.MyClientVariable = "Value from ReactiveAppA!"
. This sets a value to the variable once the app starts running. - Add a Block to MainFlow and name it BlockWithClientVariable. Drag an Expression Widget to the Block and enter
Client.MyClientVariable
in the Expression Value of the Widget. - Drag BlockWithClientVariable to the Screen.
- Set Public property of BlockWithClientVariable to Yes.
- Publish the app and open it in a browser.
Create the second app and pass it the value of Client Variable
The following steps show how to share the Client Variable between apps by reusing the block created in the previous section.
- Create another sample Reactive Web App, name it ReactiveAppB, and add a Web Module to it. Again, add a Screen to the app.
- Open Manage Dependencies, search for ReactiveAppA in Producers and select BlockWithClientVariable. Click Apply to add references and close the dialog.
- Drag the BlockWithClientVariable to the Screen.
- Publish the app and open it in a browser.
Sharing values in Traditional Web Apps
In Traditional Web Apps, you can use Session Variables to keep configurations and app context data.