FluentSignals.Blazor 1.1.3

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

FluentSignals.Blazor

Blazor integration for FluentSignals - A powerful reactive state management library. This package provides Blazor-specific components, SignalBus for inter-component communication, and helpers to make working with signals in Blazor applications seamless and efficient.

Features

  • 📡 SignalBus - Publish/Subscribe pattern for component communication
  • 📬 Queue-based subscriptions - Receive messages even if published before subscription
  • 🎯 Resource components - Display any async resource with loading/error states
  • 🔌 SignalR integration - Real-time data with ResourceSignalRView
  • 🌐 HTTP Resource components - Ready-to-use components for HTTP resources
  • 🎯 SignalComponentBase - Base component class with signal integration
  • Automatic UI updates - Components automatically re-render when signals change
  • 🔄 Lifecycle integration - Proper subscription cleanup on component disposal

Installation

dotnet add package FluentSignals.Blazor

Quick Start

Basic Setup

// Program.cs
builder.Services.AddFluentSignalsBlazor(options =>
{
    options.WithBaseUrl("https://api.example.com")
           .WithTimeout(TimeSpan.FromSeconds(30));
});

// Or with SignalBus
builder.Services.AddFluentSignalsBlazorWithSignalBus();

Components

HttpResourceView

A component for displaying HTTP resources with built-in loading, error, and success states. The component exposes a Resource property that provides access to the underlying HttpResource for advanced scenarios like custom event handling and manual refresh.

ResourceSignalView

A generic component for displaying any async resource with automatic state management.

ResourceSignalRView

A specialized component for SignalR real-time data with connection status display.

SignalComponentBase

A base component class that provides automatic signal integration and lifecycle management.

Typed HTTP Resources with Factory

Create strongly-typed HTTP resource classes with automatic dependency injection:

// Define your resource with the HttpResource attribute
[HttpResource("/api/users")]
public class UserResource : TypedHttpResource
{
    // Parameterless constructor required for factory
    public UserResource() { }
    
    public HttpResourceRequest<User> GetById(int id) => 
        Get<User>($"{BaseUrl}/{id}");
    
    public HttpResourceRequest<IEnumerable<User>> GetAll() => 
        Get<IEnumerable<User>>(BaseUrl);
    
    public HttpResourceRequest<User> Create(User user) => 
        Post<User>(BaseUrl, user);
    
    public HttpResourceRequest<User> Update(int id, User user) => 
        Put<User>($"{BaseUrl}/{id}", user);
    
    public HttpResourceRequest Delete(int id) => 
        Delete($"{BaseUrl}/{id}");
}

Register and use typed resources with factory:

// Registration in Program.cs
services.AddFluentSignalsBlazor(options => 
{
    options.BaseUrl = "https://api.example.com";
});
services.AddTypedHttpResourceFactory<UserResource>();

// Usage in components
@inject ITypedHttpResourceFactory<UserResource> UserFactory

@code {
    private UserResource? users;
    private HttpResource? userResource;
    
    protected override async Task OnInitializedAsync()
    {
        // Create resource with DI-configured HttpClient
        users = UserFactory.Create();
        
        // Or create with custom options
        users = UserFactory.Create(options => 
        {
            options.Timeout = TimeSpan.FromSeconds(60);
        });
        
        // Execute requests
        userResource = await users.GetById(123).ExecuteAsync();
        userResource.OnSuccess(() => ShowNotification("User loaded!"));
    }
}

Alternatively, inject the resource directly:

@inject UserResource Users

@code {
    protected override async Task OnInitializedAsync()
    {
        var resource = await Users.GetById(123).ExecuteAsync();
        resource.OnSuccess(() => ShowNotification("User loaded!"));
    }
}

Advanced Typed Resources

Create fully typed custom methods for complex scenarios:

[HttpResource("/api/v2")]
public class AdvancedApiResource : TypedHttpResource
{
    public AdvancedApiResource() { }
    
    // Typed search with complex criteria
    public HttpResourceRequest<SearchResult<Product>> SearchProducts(ProductSearchCriteria criteria)
    {
        return Post<ProductSearchCriteria, SearchResult<Product>>($"{BaseUrl}/products/search", criteria)
            .WithHeader("X-Search-Version", "2.0")
            .ConfigureResource(r => 
            {
                r.OnSuccess(result => Console.WriteLine($"Found {result.Data.TotalCount} products"));
                r.OnNotFound(() => Console.WriteLine("No products found"));
            });
    }
    
    // Batch operations with progress tracking
    public HttpResourceRequest<BatchResult> ProcessBatch(BatchRequest batch)
    {
        return Post<BatchRequest, BatchResult>($"{BaseUrl}/batch", batch)
            .WithHeader("X-Batch-Id", Guid.NewGuid().ToString())
            .ConfigureResource(r => 
            {
                r.IsLoading.Subscribe(loading => 
                {
                    if (loading) ShowProgress("Processing batch...");
                    else HideProgress();
                });
            });
    }
    
    // File upload with typed metadata
    public HttpResourceRequest<UploadResult> UploadFile(Stream file, FileMetadata metadata)
    {
        return BuildRequest<UploadResult>($"{BaseUrl}/files")
            .WithMethod(HttpMethod.Post)
            .WithBody(new { file, metadata })
            .WithHeader("Content-Type", "multipart/form-data")
            .WithQueryParam("category", metadata.Category)
            .Build()
            .ConfigureResource(r => r.OnServerError(() => ShowError("Upload failed")));
    }
}

// Usage in component
@inject ITypedHttpResourceFactory<AdvancedApiResource> ApiFactory

@code {
    private async Task SearchProducts()
    {
        var api = ApiFactory.Create();
        var criteria = new ProductSearchCriteria 
        { 
            Query = searchText, 
            MinPrice = 10, 
            MaxPrice = 100 
        };
        
        var resource = await api.SearchProducts(criteria).ExecuteAsync();
        // Resource will handle success/error states automatically
    }
}

SignalBus

The SignalBus provides a publish/subscribe pattern for component communication with support for both standard and queue-based subscriptions.

Documentation

For detailed documentation and examples, visit our GitHub repository.

License

This project is licensed under the MIT License.

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 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. 
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
2.1.5 110 7/17/2025
2.1.4 115 7/17/2025
2.1.3 133 7/15/2025
2.1.2 128 7/15/2025
2.1.1 141 7/8/2025
2.1.0 133 7/8/2025
2.0.0 136 6/29/2025
1.1.3 148 6/19/2025
1.1.2 147 6/17/2025
1.1.1 140 6/16/2025
1.1.0 138 6/16/2025
1.0.0 131 6/15/2025

v1.1.3: BREAKING: Removed example code from library. Added TypedHttpResourceFactory for DI integration. Enhanced HttpResourceView with Resource property exposure. See https://github.com/yourusername/FluentSignals/blob/main/CHANGELOG.md for details.