Fluxor.Blazor.Persistence
1.2.2
See the version list below for details.
dotnet add package Fluxor.Blazor.Persistence --version 1.2.2
NuGet\Install-Package Fluxor.Blazor.Persistence -Version 1.2.2
<PackageReference Include="Fluxor.Blazor.Persistence" Version="1.2.2" />
paket add Fluxor.Blazor.Persistence --version 1.2.2
#r "nuget: Fluxor.Blazor.Persistence, 1.2.2"
// Install Fluxor.Blazor.Persistence as a Cake Addin #addin nuget:?package=Fluxor.Blazor.Persistence&version=1.2.2 // Install Fluxor.Blazor.Persistence as a Cake Tool #tool nuget:?package=Fluxor.Blazor.Persistence&version=1.2.2
blazor-fluxor-persistence
Fluxor state persistence for web blazor application using LocalStorage. Currently supports LocalStorage only. Supports LocalStorage persistence only which is default, if set to other options - state will not persist.
Usage
In Program.cs file Add UsePersistence to FluxorOptions
Install Fluxor.Blazor.Persistence
Add below code to the program.cs file
builder.Services
.AddFluxor(o =>
{
o.ScanAssemblies(typeof(Program).Assembly)
.UseRouting()
.UsePersistence();
});
Using routing middleware but do not want to persist routes (default value for PersistOptions.PersistRoutes is true)
builder.Services
.AddFluxor(o =>
{
o.ScanAssemblies(typeof(Program).Assembly)
.UseRouting()
.UsePersistence(x => x.PersistRoutes = false);
});
Exceptions
Any exception thrown when loading/saving the persist state are added to `StatePersistenceFailureState' This errors can be retrieved from state
This exceptions are cleared on browser refresh or close. The exceptions can also be cleared by dispatching action
e.g. Razor component 'StateErrors.razor'
@page "/persist-state-errors"
@inherits FluxorComponent
@using Fluxor.Blazor.Persistence.Store
@inject IState<StatePersistenceFailureState> State
@inject IDispatcher Dispatcher;
<h3>Errors</h3>
@if (State.Value.Errors.Count == 0)
{
<div>No Errors</div>
}
else
{
@foreach(var e in State.Value.Errors)
{
<div class="row">
<span class="col1">@e.ActionType</span>
<span class="col2">@e.FeatureName</span>
<span class="col3">@e.Exception?.Message</span>
</div>
}
<button class="btn btn-outline" @onclick="ClearErrors">Clear Errors</button>
}
@code {
protected override void OnInitialized()
{
base.OnInitialized();
}
public void ClearErrors()
{
Dispatcher.Dispatch(new ClearStatePersistenceFailureStateAction());
}
}
Release 1.2.0 change log
public class PersistOtions
{
public PersistenceType PersistenceType { get; set; } = PersistenceType.LocalStorage;
public string PersistenceKey { get; set; } = "Fluxor.Blazor.Persistence";
public bool PersistRoutes { get; set; } = true;
}
Added new PersistRoutes flag - default true.
Release 1.2.1 change log
Issue: Persisted state for the feature is null, causes initial state to be null.
Fix: do not restore feature state if persisted loaded state is null.
Release 1.2.2 change log
Added .net7.0 as target framework
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Blazored.LocalStorage (>= 4.4.0)
- Fluxor (>= 5.9.1)
- Fluxor.Blazor.Web (>= 5.9.1)
-
net7.0
- Blazored.LocalStorage (>= 4.4.0)
- Fluxor (>= 5.9.1)
- Fluxor.Blazor.Web (>= 5.9.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.