Local Storage Help

Local Storage Help

  

I am developing a mobile application and storing user table information during login in a Local Storage table. I need to get this information from the active session on almost every screen of the application and I need help to make using best practices. This data I use to perform the filter on other tables. If I get the data from fetch, I can not guarantee that the order will be necessary for this data to be filled when I use it in the filter of another table. If I put it in the "OnInitialize", the platform generates a warning saying that it is not advisable to access Local Storage in this event. If I create a "client function", Local Storage is not accessible, what should I do? This is necessary because I am using data from another system to validate the user login.

Hi,

Option 1

You can fetch your session data from local storage first and in the onafterfetch event put an aggravate on the other tables that is based on your storage data.

Option 2

Do above on first screen or after login. Pass the session data record as input to other screens so that it is immediately available in fetch data for the other tables.

Regards,

Danirl

Hello Saulo,

You can have a look at the mobile best practices in our documentaiton.

I'm afraid I don't understand you particular use case and what gets filtered by the user, since there can be (preferably) only one active user of the app. It seems that you could benefit from better adapting your local entities and implementing offline sync. In that case you may read and the offline checklist as well.

I hope this helps.

Thanks for your response:

In option 1, I can't mix "onafterfetch" between local and remote database, that is my case.


In option 2, after first login, the flow goes from splash to the HomeScreen, in this case I can't get the data, because it will be get on login screen


Daniël Kuhlmann wrote:

Hi,

Option 1

You can fetch your session data from local storage first and in the onafterfetch event put an aggravate on the other tables that is based on your storage data.

Option 2

Do above on first screen or after login. Pass the session data record as input to other screens so that it is immediately available in fetch data for the other tables.

Regards,

Danirl



Saulo Goncalves wrote:

I am developing a mobile application and storing user table information during login in a Local Storage table. I need to get this information from the active session on almost every screen of the application and I need help to make using best practices. This data I use to perform the filter on other tables. If I get the data from fetch, I can not guarantee that the order will be necessary for this data to be filled when I use it in the filter of another table. If I put it in the "OnInitialize", the platform generates a warning saying that it is not advisable to access Local Storage in this event. If I create a "client function", Local Storage is not accessible, what should I do? This is necessary because I am using data from another system to validate the user login.

Hi,

I came across this issue today, something like yours.

My requirement : Need to hold some data that I want to use across multiple screen & which was changeable.

Data Like : User Info & Roles & Permissions in the Entire App Life-cycle.


Some of the below solutions  I found on forum:

1- Site Properties [ But it would be a bad practice in terms of performance]

2- Holding a var on selection & passing to each navigated screen [ Quite Bad]

3- Creating an entity of roles & updating the status of selected in it & using it's Aggregate in all Screen with a filter to get the active one. [ I have to use the aggregate on all the screen where I need this]


I went through the 3rd one.

I made it this way:

- Created a Local Entity 

- Created a client action for Update & Get with the Local Entity Aggregate

- Using the Client Action wherever I'll need to fetch the active Role in app

By using client Action, I skipped all the aggregates to be used in each screen where I required the User Data, You can bind your required attributes as an Output & can use anywhere in Actions on Screen easily.

You can refer my today's Forum Thread:

What is the best approach to hold a global value in mobile app ?


Cheers,

Assif