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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ESCd.AspNetCore.Components.Stateful" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ESCd.AspNetCore.Components.Stateful" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ESCd.AspNetCore.Components.Stateful" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ESCd.AspNetCore.Components.Stateful --version 1.0.1
                    
#r "nuget: ESCd.AspNetCore.Components.Stateful, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ESCd.AspNetCore.Components.Stateful@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ESCd.AspNetCore.Components.Stateful&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ESCd.AspNetCore.Components.Stateful&version=1.0.1
                    
Install as a Cake Tool

ESCd.AspNetCore.Components.Stateful

Version

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 utilize init properties, along with ReadOnly/Immutable types 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 static methods upon the State{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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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