CP.AspNetCore.SignalR.Client.Rx
1.4.5
dotnet add package CP.AspNetCore.SignalR.Client.Rx --version 1.4.5
NuGet\Install-Package CP.AspNetCore.SignalR.Client.Rx -Version 1.4.5
<PackageReference Include="CP.AspNetCore.SignalR.Client.Rx" Version="1.4.5" />
<PackageVersion Include="CP.AspNetCore.SignalR.Client.Rx" Version="1.4.5" />
<PackageReference Include="CP.AspNetCore.SignalR.Client.Rx" />
paket add CP.AspNetCore.SignalR.Client.Rx --version 1.4.5
#r "nuget: CP.AspNetCore.SignalR.Client.Rx, 1.4.5"
#:package CP.AspNetCore.SignalR.Client.Rx@1.4.5
#addin nuget:?package=CP.AspNetCore.SignalR.Client.Rx&version=1.4.5
#tool nuget:?package=CP.AspNetCore.SignalR.Client.Rx&version=1.4.5
CP.AspNetCore.SignalR.Client.Rx
Reactive Extensions for Microsoft.AspNetCore.SignalR.Client
Installation
Install-Package CP.AspNetCore.SignalR.Client.Rx
Overview
CP.AspNetCore.SignalR.Client.Rx provides a set of high-performance, memory-efficient Reactive Extensions (Rx) for SignalR client applications. It enables idiomatic, composable, and observable-based programming for SignalR events, streaming, and connection management.
- Targets: .NET Standard 2.0, .NET Framework 4.6.2, .NET 8, .NET 9
- 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<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;
using System.Reactive.Disposables;
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<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 connection on some trigger (e.g., button click)
// disposables.Add(button.Events().Click.Start(connection).Subscribe());
});
Streaming from the Server
connection.StreamObservable<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<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<string>("ReceiveMessage")
.Subscribe(msg => /* update UI */);
Connection.StartObservable().Subscribe();
}
}
API Reference
Event Subscription
On(string methodName)
— No-arg handlerOn<T>(string methodName)
On<T1, T2>(string methodName)
- ... up to 8 arguments
Connection Lifecycle
StartObservable([CancellationToken])
StartObservable(int? retryCount, [CancellationToken])
StopObservable([CancellationToken])
StopObservable(int? retryCount, [CancellationToken])
EnsureStarted([CancellationToken])
StateChanges()
WaitForState(HubConnectionState)
Streaming
StreamObservable<T>(string methodName, [CancellationToken], params object?[] args)
Invocation
InvokeObservable<T>(string methodName, [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
CompositeDisposable
for managing multiple subscriptions. - Prefer
StartObservable
/StopObservable
for connection management in Rx scenarios. - Use
StreamObservable
for 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 | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.0-rc.1.25451.107)
- System.Reactive (>= 6.0.2)
-
.NETStandard 2.0
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.0-rc.1.25451.107)
- System.Reactive (>= 6.0.2)
-
net10.0
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.0-rc.1.25451.107)
- System.Reactive (>= 6.0.2)
-
net8.0
- Microsoft.AspNetCore.SignalR.Client (>= 8.0.20)
- System.Reactive (>= 6.0.2)
-
net9.0
- Microsoft.AspNetCore.SignalR.Client (>= 9.0.9)
- System.Reactive (>= 6.0.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CP.AspNetCore.SignalR.Client.Rx:
Package | Downloads |
---|---|
SignalRChatClient
An Extension of the Microsoft.AspNetCore.SignalR.Client library |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.4.5 | 252 | 9/18/2025 |
1.3.2 | 159 | 9/10/2025 |
1.2.17 | 547 | 3/25/2025 |
1.2.11 | 122 | 1/16/2025 |
1.2.2 | 151 | 11/20/2024 |
1.1.15 | 217 | 9/18/2024 |
1.1.10 | 158 | 8/7/2024 |
1.1.8 | 166 | 6/25/2024 |
1.1.4 | 183 | 5/24/2024 |
1.1.2 | 166 | 5/24/2024 |
1.0.41 | 196 | 3/12/2024 |
1.0.24 | 228 | 1/10/2024 |
1.0.20 | 171 | 1/9/2024 |
1.0.19 | 166 | 1/9/2024 |
1.0.17 | 229 | 12/11/2023 |
1.0.15 | 185 | 11/27/2023 |
1.0.14 | 173 | 11/27/2023 |
1.0.13 | 130 | 11/27/2023 |
1.0.11 | 150 | 11/13/2023 |
1.0.9 | 163 | 11/8/2023 |
1.0.8 | 161 | 11/8/2023 |
1.0.7 | 144 | 11/8/2023 |
1.0.5 | 175 | 10/2/2023 |
1.0.1 | 185 | 9/20/2023 |
Compatability with Net 6 / 7 and net462