CP.AspNetCore.SignalR.Client.Rx.Reactive
1.6.0
dotnet add package CP.AspNetCore.SignalR.Client.Rx.Reactive --version 1.6.0
NuGet\Install-Package CP.AspNetCore.SignalR.Client.Rx.Reactive -Version 1.6.0
<PackageReference Include="CP.AspNetCore.SignalR.Client.Rx.Reactive" Version="1.6.0" />
<PackageVersion Include="CP.AspNetCore.SignalR.Client.Rx.Reactive" Version="1.6.0" />
<PackageReference Include="CP.AspNetCore.SignalR.Client.Rx.Reactive" />
paket add CP.AspNetCore.SignalR.Client.Rx.Reactive --version 1.6.0
#r "nuget: CP.AspNetCore.SignalR.Client.Rx.Reactive, 1.6.0"
#:package CP.AspNetCore.SignalR.Client.Rx.Reactive@1.6.0
#addin nuget:?package=CP.AspNetCore.SignalR.Client.Rx.Reactive&version=1.6.0
#tool nuget:?package=CP.AspNetCore.SignalR.Client.Rx.Reactive&version=1.6.0
CP.AspNetCore.SignalR.Client.Rx
ReactiveUI.Primitives extensions for Microsoft.AspNetCore.SignalR.Client.
Installation
Install-Package CP.AspNetCore.SignalR.Client.Rx
Use the lean package above when the application does not otherwise depend on System.Reactive. Applications that require System.Reactive interoperability can install the shared-source variant:
Install-Package CP.AspNetCore.SignalR.Client.Rx.Reactive
Overview
CP.AspNetCore.SignalR.Client.Rx provides high-performance, memory-efficient observable APIs for SignalR client applications. The lean package is based on ReactiveUI.Primitives; the .Reactive package uses ReactiveUI.Primitives.Reactive and the CP.AspNetCore.SignalR.Client.Rx.Reactive namespace.
- Targets: .NET Framework 4.6.2, .NET 8, .NET 9, .NET 10, and .NET 11
- Supports: WPF, WinForms, Console, ASP.NET Core, Razor Pages, and more
Quick Start
using CP.AspNetCore.SignalR.Client.Rx;
using Microsoft.AspNetCore.SignalR.Client;
var connection = new HubConnectionBuilder()
.WithUrl("http://localhost:5000/hub")
.WithAutomaticReconnect()
.Build();
// Subscribe to a hub method
var sub = connection.On(new HubMethod<string>("Stream")).Subscribe(Console.WriteLine);
// Start the connection reactively
connection.StartObservable().Subscribe();
Advanced Usage
Using HubBuilder for Lifecycle Management
using CP.AspNetCore.SignalR.Client.Rx;
HubBuilder.Create(builder => builder.WithUrl("https://localhost:53933/ChatHub"))
.Subscribe(x =>
{
var connection = x.hubConnection;
var disposables = x.disposables;
// Listen for messages
disposables.Add(connection.On(new HubMethod<(string, string)>("ReceiveMessage"))
.Subscribe(msg => Console.WriteLine($"{msg.t1}: {msg.t2}")));
// Handle connection closed
disposables.Add(connection.HasClosed().Subscribe(error =>
Console.WriteLine($"Closed: {error?.Message}")));
// Start the connection from any observable trigger.
// disposables.Add(connectRequested.Start(connection).Subscribe());
});
Streaming from the Server
connection.StreamObservable(new HubMethod<int>("Counter"), CancellationToken.None, 10)
.Subscribe(
value => Console.WriteLine($"Received: {value}"),
ex => Console.WriteLine($"Error: {ex.Message}"),
() => Console.WriteLine("Stream completed"));
Invoking Methods and Sending Data
// Invoke a method and get a result
connection.InvokeObservable(new HubMethod<int>("AddNumbers"), CancellationToken.None, 1, 2)
.Subscribe(result => Console.WriteLine($"Sum: {result}"));
// Send a method (fire-and-forget)
connection.SendObservable("Notify", CancellationToken.None, "Hello!")
.Subscribe(_ => Console.WriteLine("Notification sent"));
Observing Connection State
connection.StateChanges().Subscribe(state =>
Console.WriteLine($"Connection state: {state}"));
// Wait for a specific state
connection.WaitForState(HubConnectionState.Connected)
.Subscribe(_ => Console.WriteLine("Connected!"));
Razor Pages Example
@page
@using CP.AspNetCore.SignalR.Client.Rx
@inject Microsoft.AspNetCore.SignalR.Client.HubConnection Connection
@functions {
protected override void OnInitialized()
{
Connection.On(new HubMethod<string>("ReceiveMessage"))
.Subscribe(msg => /* update UI */);
Connection.StartObservable().Subscribe();
}
}
API Reference
Event Subscription
On(string methodName)— No-arg handlerOn<T>(HubMethod<T> method)On<T1, T2>(HubMethod<(T1, T2)> method)- ... up to 8 arguments
Connection Lifecycle
StartObservable()/StartObservable(CancellationToken)StartObservable(int? retryCount, CancellationToken)StopObservable()/StopObservable(CancellationToken)StopObservable(int? retryCount, CancellationToken)EnsureStarted()/EnsureStarted(CancellationToken)StateChanges()WaitForState(HubConnectionState)
Streaming
StreamObservable<T>(HubMethod<T> method, CancellationToken, params object?[] args)
Invocation
InvokeObservable<T>(HubMethod<T> method, CancellationToken, params object?[] args)InvokeObservable(string methodName, CancellationToken, params object?[] args)SendObservable(string methodName, CancellationToken, params object?[] args)
Connection Events
HasClosed()IsReconnecting()HasReconnected()
HubBuilder
HubBuilder.Create(Func<HubConnectionBuilder, IHubConnectionBuilder>)
Best Practices
- Always dispose subscriptions to avoid memory leaks.
- Use the disposable scope returned by
HubBuilder.Createfor managing multiple subscriptions. - Prefer
StartObservable/StopObservablefor connection management in Rx scenarios. - Use
StreamObservablefor server-to-client streaming.
License
MIT
See Also
CP.AspNetCore.SignalR.Client.Rx - Empowering Industrial Automation with Reactive Technology ⚡🏭
| 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 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 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. net11.0 is compatible. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 is compatible. net481 is compatible. |
-
.NETFramework 4.6.2
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.10)
- ReactiveUI.Primitives.Reactive (>= 7.1.0)
-
.NETFramework 4.7.2
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.10)
- ReactiveUI.Primitives.Reactive (>= 7.1.0)
-
.NETFramework 4.8
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.10)
- ReactiveUI.Primitives.Reactive (>= 7.1.0)
-
.NETFramework 4.8.1
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.10)
- ReactiveUI.Primitives.Reactive (>= 7.1.0)
-
net10.0
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.10)
- ReactiveUI.Primitives.Reactive (>= 7.1.0)
-
net11.0
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.10)
- ReactiveUI.Primitives.Reactive (>= 7.1.0)
-
net8.0
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.10)
- ReactiveUI.Primitives.Reactive (>= 7.1.0)
-
net9.0
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.10)
- ReactiveUI.Primitives.Reactive (>= 7.1.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 |
|---|---|---|
| 1.6.0 | 119 | 8/2/2026 |
Compatibility with .NET 8 / 9 / 10 / 11 and .NET Framework 4.6.2 / 4.7.2 / 4.8 / 4.8.1