DEV Community

Discussion on: Advanced Blazor State Management Using Fluxor, part 6 - Persisting State

Collapse
 
padnom profile image
padnom • Edited

Great job and thx for that's!
I performed a similar approach but instead of have a save and load action.
I persist state, each time state changed and I load form local storage only when counter.state.value is null.

Collapse
 
mr_eking profile image
Eric King

I'm glad you got it working. There's probably a million ways to go about it.

But I do have a question... I'm wondering when Counter.State.Value is null? If Fluxor is initialized correctly, no State should ever be null. You provide a non-null initial State in the Feature.

Collapse
 
padnom profile image
padnom

You right. It was a shorthand to explain what I do
In my code I use it for display username (string)
var login = loginSate.Value.LoginBackOffice;
if (login.Status == EnumStateLogin.NotInstantiate)
{
return await loginSessionStorage.GetLoginAsync(); ;
}
return login;