SimpleFlux.NET
3.0.0
dotnet add package SimpleFlux.NET --version 3.0.0
NuGet\Install-Package SimpleFlux.NET -Version 3.0.0
<PackageReference Include="SimpleFlux.NET" Version="3.0.0" />
<PackageVersion Include="SimpleFlux.NET" Version="3.0.0" />
<PackageReference Include="SimpleFlux.NET" />
paket add SimpleFlux.NET --version 3.0.0
#r "nuget: SimpleFlux.NET, 3.0.0"
#:package SimpleFlux.NET@3.0.0
#addin nuget:?package=SimpleFlux.NET&version=3.0.0
#tool nuget:?package=SimpleFlux.NET&version=3.0.0
SimpleFluxDotNet
A simple Flux architecture implementation for .NET applications with minimal dependencies and boilerplate code. Particularly useful for Blazor applications.
Features
- ðŠķ Lightweight Flux implementation
- ⥠First-class Blazor support
- ðĶ Minimal dependencies
- ð Type-safe state management
- ð Easy integration with dependency injection
- ð Built-in middleware support
Installation
Install via NuGet:
dotnet add package SimpleFlux.NET
Quick Start
- Define your state:
public sealed record ExampleState : AbstractFluxState
{
public int Counter { get; init; }
public WeatherForecast[]? Forecasts { get; init; }
}
- Create actions:
public sealed record IncrementCounterButtonClickedAction : IFluxAction { }
- Create a reducer:
public sealed class IncrementCounterReducer : IFluxReducer<ExampleState, IncrementCounterButtonClickedAction>
{
public ExampleState Reduce(IncrementCounterButtonClickedAction action, ExampleState currentState) => currentState with
{
Counter = currentState.Counter + 1
};
}
- Set up in your Blazor application:
builder.Services.AddFluxStateManagement(flux =>
{
flux.ConfigureStateContainer<ExampleState>(state =>
{
state.HandleAction<IncrementCounterButtonClickedAction>(action =>
action.UseReducer<IncrementCounterReducer>());
// You can also define inline reducers
state.HandleAction<SomeOtherAction>(action =>
{
action.UseReducer(static (action, state) => state with
{
// Update state here
});
});
// Or use middleware for side effects
state.HandleAction<LoadDataAction>(action =>
action.UseMiddleware<LoadDataMiddleware>());
});
});
- Use in components:
@page "/counter"
@using SimpleFluxDotNet.Abstractions
@inherits FluxComponent<ExampleState>
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @State.Current.Counter</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private Task IncrementCount() =>
State.DispatchAsync(new IncrementCounterButtonClickedAction());
}
Project Structure
SimpleFluxDotNet- Core library with Flux implementationSimpleFluxDotNet.Example- Example Blazor application showcasing usageSimpleFluxDotNet.Tests- Unit tests
Documentation
Core Concepts
- State: Immutable state container that holds your application's data
- Actions: Plain objects describing what happened
- Reducers: Pure functions that specify how the state changes in response to actions
- Store: Holds the state and handles dispatching of actions
- Middleware: Intercepts actions for side effects, logging, etc.
Components
IFluxAction
The base interface for all actions in your application.
AbstractFluxState
Base class for your application's state objects.
FluxComponent
Base component class that provides access to state and dispatch capabilities.
IFluxReducer<TState, TAction>
Interface for implementing reducers that handle specific action types. Reducers are pure functions that take the current state and an action, and return a new state.
public interface IFluxReducer<TState, TAction> where TState : AbstractFluxState where TAction : IFluxAction
{
TState Reduce(TAction action, TState currentState);
}
IFluxMiddleware<TState, TAction>
Interface for implementing middleware that handles side effects for specific action types. Middleware can perform async operations and dispatch additional actions.
public interface IFluxMiddleware<TState, TAction> where TState : AbstractFluxState where TAction : IFluxAction
{
Task HandleAsync(TAction action, TState currentState, IFluxDispatcher dispatcher);
}
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. 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 was computed. 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. |
-
net8.0
- Microsoft.AspNetCore.Components (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 474 | 10/4/2025 |
| 3.0.0-preview006 | 206 | 9/26/2025 |
| 3.0.0-preview003 | 236 | 9/22/2025 |
| 3.0.0-preview001 | 241 | 9/21/2025 |
| 2.6.1 | 377 | 9/16/2025 |
| 2.6.0 | 326 | 9/16/2025 |
| 2.5.1 | 461 | 3/5/2024 |
| 2.5.0 | 209 | 2/26/2024 |
| 2.4.0 | 168 | 2/26/2024 |