FluentSignals.SignalBus 2.1.0

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

FluentSignals SignalBus

The SignalBus is a messaging system built on top of FluentSignals that provides a publish-subscribe pattern for communication between components in Blazor applications.

Features

  • Type-safe messaging: Strongly-typed message publishing and consumption
  • Async support: Both synchronous and asynchronous message handlers
  • Scoped subscriptions: Automatic cleanup with component lifecycle
  • Built on FluentSignals: Leverages the reactive signal system internally

Installation

Add the SignalBus services to your Blazor application:

// In Program.cs
builder.Services.AddFluentSignalsBlazorWithSignalBus();

// Register consumers for specific message types
builder.Services.AddSignalConsumer<MyMessage>();

Usage

Define Message Types

public class UserNotification
{
    public string Message { get; set; }
    public DateTime Timestamp { get; set; }
}

Publishing Messages

@inject ISignalPublisher Publisher

@code {
    private void SendNotification()
    {
        var notification = new UserNotification
        {
            Message = "Hello from SignalBus!",
            Timestamp = DateTime.Now
        };
        
        Publisher.Publish(notification);
    }
}

Consuming Messages

@inject ISignalConsumer<UserNotification> NotificationConsumer
@implements IDisposable

@code {
    private ISignalSubscriptionContract? _subscription;
    
    protected override void OnInitialized()
    {
        _subscription = NotificationConsumer.Subscribe(notification =>
        {
            // Handle notification
            Console.WriteLine($"Received: {notification.Message}");
            StateHasChanged();
        });
    }
    
    public void Dispose()
    {
        _subscription?.Dispose();
    }
}

Async Message Handling

_subscription = NotificationConsumer.Subscribe(async notification =>
{
    await ProcessNotificationAsync(notification);
    StateHasChanged();
});

Advanced Usage

Using the Factory

@inject SignalConsumerFactory ConsumerFactory

@code {
    private ISignalConsumer<MyMessage> _consumer;
    
    protected override void OnInitialized()
    {
        _consumer = ConsumerFactory.CreateConsumer<MyMessage>();
        // Subscribe to messages...
    }
}

Direct Signal Access

For advanced scenarios, you can access the underlying signal:

var signal = consumer.Signal;
// Use signal directly for complex reactive patterns

Architecture

The SignalBus consists of:

  • ISignalPublisher: Interface for publishing messages
  • ISignalConsumer<T>: Interface for consuming typed messages
  • SignalBus: Internal implementation managing signal routing
  • SignalPublisher: Implementation of ISignalPublisher
  • SignalConsumer<T>: Implementation wrapping typed signals

All message routing is handled through FluentSignals' TypedSignal<T> instances, providing reactive updates when messages are published.

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 (1)

Showing the top 1 NuGet packages that depend on FluentSignals.SignalBus:

Package Downloads
FluentSignals.Blazor

Blazor integration for FluentSignals - A reactive state management library. Includes SignalBus for component communication, HTTP resource components, typed resource factories, and Blazor-specific helpers.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.5 144 7/17/2025
2.1.4 145 7/17/2025
2.1.3 142 7/15/2025
2.1.2 156 7/9/2025
2.1.1 146 7/8/2025
2.1.0 149 7/8/2025
2.0.0 148 6/29/2025

Initial release of FluentSignals.SignalBus - Event bus functionality extracted from FluentSignals.Blazor.