Persist meta data for a given user session

I’m building a Hybrid mobile app for an existing web application (non Mendix).  We have a situation where we need to call a REST API to get the meta data for the application. It basically key/value pairs which is needed to show nice display names in UI. Once the data is loaded, I want to use it across current user session without loading it again. In the existing web application, it is loaded on client only once, converted to global Map, and re-used.  What is the recommended practice to achieve this in Mendix?
3 answers

I guess since its applicable through out the user session, you may associate the mapped response entity to the Either the Session entity itself or Account entity (can refresh this at the time of login) itself.

  1. You can create snippet with a data widget inside it.
  2. Then you can get the required entity in data widget with source as Microflow. Inside Microflow you can retrieve the response object from the association with currentSession.
  3. Put this snippet in the Master layout which you use through out the application.



Just a thought: are the key value pairs translations of the screen texts?

In that case, including the texts in the model in would be my first choice: 



A few ideas beyond associating the metadata to your session (which might work just fine):

With your current architecture: use localStorage

  • You could use the local storage getter and setter functions from NanoflowCommons to store and retrieve this data in nanoflows as needed


With a native app (or offline hybrid app): use the on-device database

  • For your regular REST calls, call microflows from nanoflows to get your data as non-persisted entities
  • For the metadata, treat them as persisted entities. Use a microflow to fetch from the API, and then use the sync that data to the user’s device . Any time you need the metadata, you can retrieve it using a standard database retrieve from a nanoflow.