ESCd.AspNetCore.Components.Stateful
1.0.1
dotnet add package ESCd.AspNetCore.Components.Stateful --version 1.0.1
NuGet\Install-Package ESCd.AspNetCore.Components.Stateful -Version 1.0.1
<PackageReference Include="ESCd.AspNetCore.Components.Stateful" Version="1.0.1" />
<PackageVersion Include="ESCd.AspNetCore.Components.Stateful" Version="1.0.1" />
<PackageReference Include="ESCd.AspNetCore.Components.Stateful" />
paket add ESCd.AspNetCore.Components.Stateful --version 1.0.1
#r "nuget: ESCd.AspNetCore.Components.Stateful, 1.0.1"
#:package ESCd.AspNetCore.Components.Stateful@1.0.1
#addin nuget:?package=ESCd.AspNetCore.Components.Stateful&version=1.0.1
#tool nuget:?package=ESCd.AspNetCore.Components.Stateful&version=1.0.1
ESCd.AspNetCore.Components.Stateful
Flux-like Immutable Razor Component.
Basic Usage
Stateful takes from patterns like Flux, utilizing records to represent an immutable snapshot of the components data. The abstractions of "Actions"/"Reducers" from integrations like redux redux are consolidated into a single "mutation" abstraction.
Defining State<T>
State{T}implementations should utilizeinitproperties, along withReadOnly/Immutabletypes to enforce immutability.
using ESCd.AspNetCore.Components.Stateful;
public sealed record CounterState : State<CounterState>
{
public int Count { get; init; }
}
Defining "Mutations"
"Mutations" should be static methods, if possible. It is recommended to implement mutations as
internal staticmethods upon theState{T}implementation.
using ESCd.AspNetCore.Components.Stateful;
public sealed record CounterState : State<CounterState>
{
// omitted..
internal static CounterState Decrement( CounterState state ) => state with
{
Count = state.Count - 1
};
internal static CounterState Increment( CounterState state ) => state with
{
Count = state.Count + 1
};
}
Wiring it Together (Implement the Component)
@inherits StatefulComponent<CounterState>
<div>
<h1>Counter</h1>
<button type="button" @onclick="@OnIncrement">Increment</button>
<button type="button" @onclick="@OnDecrement">Decrement</button>
<p>Count: @State.Count</p>
</div>
@code {
private Task OnDecrement() => Mutate(state => CounterState.Decrement(state));
private Task OnIncrement() => Mutate(state => CounterState.Increment(state));
}
A Complete Example
Complete examples can be found in the sample/ directory.
Something missing, still have questions? Please open an Issue or submit a PR!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components (>= 10.0.7)
-
net9.0
- Microsoft.AspNetCore.Components (>= 9.0.15)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ESCd.AspNetCore.Components.Stateful:
| Package | Downloads |
|---|---|
|
CS2Launcher.AspNetCore.App
Blazor Runtime Components for CS2 Launcher. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 124 | 4/23/2026 |
| 1.0.0 | 117 | 4/16/2026 |
| 1.0.0-rc.8 | 59 | 4/16/2026 |