Global values not always avaiable or updating in UI

Good Day

I need some assistance please.

When a user logs in the user is prompted to make selections after login.
I take these values and place them into a global variable.

This works fine until page refresh as they are then cleared.
So I place the values into ProtectedLocalStorage and i have a method that gets the values from the ProtectedLocalStorage and repopulated the global variables.

However they often not available to the UI or other getData operations. I am running the method in a service.

How would i force the UI etc to update from within this method.

Hi @DarrenW,

Once you've finished reading the data from the local storage and the global variables are set you can call StateHasChanged() to refresh the UI. You can also hide/disabled various parts of the UI if something is not yet available.

Thanks for the reply.

I have my method in GlobalService.Partial.cs, and the StateHasChanged() does not exist in the current context. What am i missing?

Do you have any suggestions for me to achieve what i am. Perhaps my whole approach is incorrect or not the most practical.

StateHasChanged() can be executed in pages or layouts. Usually pages will receive PropertyChanged event if global property is changed.