DEV Community

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

padnom profile image
padnom • Edited on

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.

mr_eking profile image
Eric King Author

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.

padnom profile image

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;