Fluxor.Blazor.Persistence
1.2.3
dotnet add package Fluxor.Blazor.Persistence --version 1.2.3
NuGet\Install-Package Fluxor.Blazor.Persistence -Version 1.2.3
<PackageReference Include="Fluxor.Blazor.Persistence" Version="1.2.3" />
paket add Fluxor.Blazor.Persistence --version 1.2.3
#r "nuget: Fluxor.Blazor.Persistence, 1.2.3"
// Install Fluxor.Blazor.Persistence as a Cake Addin #addin nuget:?package=Fluxor.Blazor.Persistence&version=1.2.3 // Install Fluxor.Blazor.Persistence as a Cake Tool #tool nuget:?package=Fluxor.Blazor.Persistence&version=1.2.3
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
Release 1.2.3 change log
Added .net5.0 as target framework Added support for session storage as persistenceType Removed nuget package Blazored.LocalStorage
builder.Services
.AddFluxor(o =>
{
o.ScanAssemblies(typeof(Program).Assembly)
.UseRouting()
.UsePersistence(x => x.PersistenceType = PersistenceType.SessionStorage);
});
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. 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. |
-
net5.0
- Fluxor (>= 5.9.1)
- Fluxor.Blazor.Web (>= 5.9.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 5.0.0)
-
net6.0
- Fluxor (>= 5.9.1)
- Fluxor.Blazor.Web (>= 5.9.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
-
net7.0
- Fluxor (>= 5.9.1)
- Fluxor.Blazor.Web (>= 5.9.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.