A reactive state management library for .NET with first-class Blazor support. FluentSignals provides a simple, type-safe way to manage application state with automatic UI updates.
- Reactive State Management: Signals automatically notify subscribers when values change
- Type-Safe: Full generic support with compile-time type checking
- Async Support: Built-in support for asynchronous operations with loading and error states
- Composite Signals: Automatically manage subscriptions to signals containing internal signals
- HTTP Resource Management: Specialized signals for HTTP operations with retry logic
- Blazor Integration: SignalComponentBase for automatic subscription management and UI updates
dotnet add package FluentSignals
dotnet add package FluentSignals.Blazor # For Blazor projects// Create a signal
var counter = new TypedSignal<int>(0);
// Subscribe to changes
counter.Subscribe(value => Console.WriteLine($"Counter: {value}"));
// Update the value
counter.Value = 5; // Outputs: Counter: 5@inherits SignalComponentBase
<div>
<p>Count: @counter.Value</p>
<button @onclick="Increment">Increment</button>
</div>
@code {
private readonly TypedSignal<int> counter = new(0);
protected override void OnInitialized()
{
base.OnInitialized();
// Automatically triggers StateHasChanged when signal changes
SubscribeForUpdate(counter);
}
private void Increment() => counter.Value++;
}var asyncSignal = new AsyncTypedSignal<string>();
// Subscribe to all state changes
asyncSignal.IsLoading.Subscribe(loading => Console.WriteLine($"Loading: {loading}"));
asyncSignal.Error.Subscribe(error => Console.WriteLine($"Error: {error?.Message}"));
asyncSignal.Subscribe(value => Console.WriteLine($"Value: {value}"));
// Execute async operation
await asyncSignal.ExecuteAsync(async () => {
await Task.Delay(1000);
return "Data loaded!";
});// Create HTTP resource
var httpResource = new HttpResource(httpClient);
// Make requests with automatic state management
await httpResource.GetAsync<User[]>("/api/users");
// Access state
if (httpResource.IsLoading.Value)
// Show loading indicator
else if (httpResource.Error.Value != null)
// Handle error
else
// Use httpResource.ValueFor more examples and detailed documentation, see the demo application in the FluentSignals.ServerTest project.
This project is licensed under the MIT License.