RxSignalrStreams.Extensions
1.0.1
dotnet add package RxSignalrStreams.Extensions --version 1.0.1
NuGet\Install-Package RxSignalrStreams.Extensions -Version 1.0.1
<PackageReference Include="RxSignalrStreams.Extensions" Version="1.0.1" />
paket add RxSignalrStreams.Extensions --version 1.0.1
#r "nuget: RxSignalrStreams.Extensions, 1.0.1"
// Install RxSignalrStreams.Extensions as a Cake Addin #addin nuget:?package=RxSignalrStreams.Extensions&version=1.0.1 // Install RxSignalrStreams.Extensions as a Cake Tool #tool nuget:?package=RxSignalrStreams.Extensions&version=1.0.1
Extensions for Reactive SignalR streaming
Since ASP.NET Core 2.1, we can now use SignalR streaming to push data to or receive data from client/server.
By design, only ChannelReader<T>
class is supported to create a stream from the server to the client. For your information, since ASP.NET Core 3.0, the IAsyncEnumerable<T>
is also supported.
If you desire to consume an IObservable<T>
from the server, you must know that you can be exposed to errors due to backpressure, the fact that the consumer can be slower than the producer which can lead to an inconsistent system. To prevent this error, there is a way to change the streaming behavior by creating a ChannelReader<T>
from an IObservable<T>
. There are currently 2 possible scenario you can encounter: ignore
or buffer
.
ToNewestValueStream
The ToNewestValueStream
method is made for the ignore
all previous values scenario. So, you will always send/receive the latest value as soon as possible even when the consumer is slower than the producer. Previous data can be skipped in favor of the latest one.
Use this scenario when you are in a I don't care about not so fresh data scenario.
public ChannelReader<int> RealtimeWeather()
{
return _realtimeValuesService.Observe()
.ToNewestValueStream(Context.ConnectionAborted);
}
ToBufferedStream
The ToBufferedStream
method is made for the buffer
all previous values scenario. So, you will always send/receive the values from the producer, even when the consumer is slower than the producer. No data will be skipped but it can take a while before having the latest data.
Be aware that it will create a buffer of all the entire data not delivered, which can drastically increase the memory footprint.
Use this scenario when you are in a I care about every single data that was sent scenario.
public ChannelReader<int> RealtimeWeather()
{
return _realtimeValuesService.Observe()
.ToBufferedStream(Context.ConnectionAborted);
}
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 was computed. 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. |
.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 was computed. 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. |
-
.NETStandard 2.0
- System.Reactive (>= 4.3.1)
- System.Threading.Channels (>= 4.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.