BlazingSingularity 1.0.0-beta.5

This is a prerelease version of BlazingSingularity.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package BlazingSingularity --version 1.0.0-beta.5
                    
NuGet\Install-Package BlazingSingularity -Version 1.0.0-beta.5
                    
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="BlazingSingularity" Version="1.0.0-beta.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazingSingularity" Version="1.0.0-beta.5" />
                    
Directory.Packages.props
<PackageReference Include="BlazingSingularity" />
                    
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 BlazingSingularity --version 1.0.0-beta.5
                    
#r "nuget: BlazingSingularity, 1.0.0-beta.5"
                    
#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 BlazingSingularity@1.0.0-beta.5
                    
#: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=BlazingSingularity&version=1.0.0-beta.5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=BlazingSingularity&version=1.0.0-beta.5&prerelease
                    
Install as a Cake Tool

BlazingSingularity

Build

WPF-style [RelayCommand] for Blazor, powered by source generators.

Installation

dotnet add package BlazingSingularity --prerelease

Usage

Code-behind

using BlazingSingularity.Commands;
using Microsoft.AspNetCore.Components;

namespace MyApp.Pages;

public partial class Counter : ComponentBase
{
    private int count = 0;

    [RelayCommand]
    private void Increment()
    {
        count++;
    }

    [RelayCommand]
    private async Task LoadData(CancellationToken cancellationToken)
    {
        await Task.Delay(1000, cancellationToken);
    }
}
@page "/counter"

<p>Count: @count</p>

<button @onclick="() => IncrementCommand.Execute()">Increment</button>

<button @onclick="() => LoadDataCommand.ExecuteAsync()"
        disabled="@LoadDataCommand.IsLoading">
    Load
</button>

Inline @code block

@page "/todos"
@using BlazingSingularity.Commands

<button @onclick="() => AddTodoCommand.Execute()">Add</button>

@foreach (var todo in todos)
{
    <p>@todo</p>
}

@code {
    private List<string> todos = [];

    [RelayCommand]
    private void AddTodo()
    {
        todos.Add($"Todo #{todos.Count + 1}");
    }
}

Error Handling with TryExecuteAsync

Use TryExecuteAsync for functional-style error handling with the Result monad:

var result = await LoadDataCommand.TryExecuteAsync();

result.Match(
    onSuccess: () => Console.WriteLine("Data loaded successfully"),
    onFailure: ex => Console.WriteLine($"Failed: {ex.Message}")
);

// Or use pattern matching
if (result.IsFailure)
{
    ErrorMessage = result.ErrorMessage;
    return;
}

The Result type provides:

  • IsSuccess / IsFailure - Check the outcome
  • Exception - Access the exception on failure
  • ErrorMessage - Shorthand for Exception?.Message
  • Match - Functional pattern matching with callbacks

Reactive State with [Signal]

Use [Signal] to create reactive state that can notify subscribers when values change:

using BlazingSingularity.Signals;

public partial class SearchPage : ComponentBase
{
    [Signal]
    private string _searchText = string.Empty;

    [Signal]
    private int? _minPrice = null;

    protected override void OnInitialized()
    {
        // Subscribe to changes
        SearchTextSignal.OnChange(newValue =>
        {
            Console.WriteLine($"Search changed to: {newValue}");
        });

        // Trigger command CanExecute re-evaluation on change
        MinPriceSignal.OnChange(SearchCommand.RaiseCanExecuteChanged);
    }

    [RelayCommand]
    private void Search() { /* ... */ }

    private bool CanSearch() => !string.IsNullOrWhiteSpace(SearchText);
}

The source generator creates:

  • A public property (SearchText) that notifies on change
  • A Signal<T> accessor (SearchTextSignal) for subscribing to changes

Use the generated property in your Razor markup:

<input @bind="SearchText" @bind:event="oninput" />

Async Data Fetching with Fetch<T>

Use Fetch<T> for reactive async data loading with built-in loading/error/success states:

using BlazingSingularity.Fetch;

public partial class TodosPage : ComponentBase, IDisposable
{
    [Inject] private HttpClient Http { get; set; } = null!;

    private Fetch<List<Todo>> TodosFetch = null!;

    protected override async Task OnInitializedAsync()
    {
        TodosFetch = new Fetch<List<Todo>>(
            ct => Http.GetFromJsonAsync<List<Todo>>("/api/todos", ct)!,
            () => InvokeAsync(StateHasChanged)
        );
        await TodosFetch.FetchAsync();
    }

    public void Dispose() => TodosFetch.Dispose();
}
@if (TodosFetch.IsLoading) { <Spinner /> }
else if (TodosFetch.IsError) { <p>Error: @TodosFetch.Error?.Message</p> }
else if (TodosFetch.HasData)
{
    @foreach (var todo in TodosFetch.Data!)
    {
        <p>@todo.Title</p>
    }
}

Stale-While-Revalidate with BackgroundFetch<T>

Use BackgroundFetch<T> to show cached data instantly while refreshing in the background:

private BackgroundFetch<OrgDto> OrgFetch = null!;

protected override async Task OnInitializedAsync()
{
    OrgFetch = new BackgroundFetch<OrgDto>(
        ct => Http.GetFromJsonAsync<OrgDto>($"/api/orgs/{OrgId}", ct)!,
        () => InvokeAsync(StateHasChanged)
    );
    OrgFetch.SetInitialData(CachedOrg);  // Display immediately
    await OrgFetch.FetchAsync();          // Refresh in background
}
<div class="@(OrgFetch.IsStale ? "opacity-50" : "")">
    @if (OrgFetch.IsRefreshing) { <SmallSpinner /> }
    <h1>@OrgFetch.Data?.Name</h1>
</div>
Product Compatible and additional computed target framework versions.
.NET 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

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
1.0.0-beta.6 131 3/19/2026
1.0.0-beta.5 208 3/18/2026
1.0.0-beta.4 117 3/11/2026
1.0.0-beta.3 172 2/7/2026
1.0.0-beta.2 110 2/5/2026
1.0.0-beta.1 958 12/4/2025