What libraries/techniques are available in Blazor for State management for webassembly (wasm).
It would be nice to know pros and cons of different approaches.
Abstract: State Management is one of the much-needed features in modern web applications. In this Blazor Tutorial, we will be discussing about the state management features provided by ASP.NET Core Blazor in browsers, which can save a round trip to the server. Blazor is a framework for building interactive client-side Web UI using .NET.
Blazor Server is a stateful app framework. Most of the time, the app maintains a connection to the server. The user's state is held in the server's memory in a circuit. Examples of user state held in a circuit include: The hierarchy of component instances and their most recent render output in the rendered UI.
Examples of user state modeled in the URL include: The ID of a viewed entity. The current page number in a paged grid. The contents of the browser's address bar are retained if the user manually reloads the page. For information on defining URL patterns with the @page directive, see ASP.NET Core Blazor routing.
An example of this is provided by the Microsoft.ASpNetCore.ProtectedBrowserStorage package. Another way to handle state is by calling an API and persisting it on the server. How it is persisted is up to you: options range from SQL, NoSQL to simple caches like Redis. BlazorState.WasmRemote.Server is an ASP.NET hosted Blazor WebAssembly app.
Redux/Flux pattern has become a leader in state management in JS word; so it would make sense to adopt this best practice.
Luckily there is already a Fluxor library that does just that; and it does have the most github stars 379
; although it is still a relatively new area; so it remains to be seen what ends up being the most adopted approach later on.
There is a great intro video along with source code
Official docs:
An in depth article.
Blazor-State
Pros: uses MediatR for messaging
https://chrissainty.com/mobile-blazor-bindings-state-management-and-data/
https://jonhilton.net/blazor-state-management/
https://docs.microsoft.com/en-us/aspnet/core/blazor/state-management
nice but mostly messaging: https://jasonwatmore.com/post/2020/07/30/aspnet-core-blazor-webassembly-communication-between-components
keywords: passing data between blazor wasm webassembly components child parent attributes events handling
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With