RxT 1.0.0
dotnet add package RxT --version 1.0.0
NuGet\Install-Package RxT -Version 1.0.0
<PackageReference Include="RxT" Version="1.0.0" />
paket add RxT --version 1.0.0
#r "nuget: RxT, 1.0.0"
// Install RxT as a Cake Addin #addin nuget:?package=RxT&version=1.0.0 // Install RxT as a Cake Tool #tool nuget:?package=RxT&version=1.0.0
Version | Downloads |
---|---|
Rx<T>
.NET Reactive Types that provide similar functionalities inspired from: (reactive
, ref
& computed
) found in Vue.js
This library provides 4 types: Reactive<T>
, ConcurrentReactive<T>
, Computed<T>
, Computed<T,R>
Example Usage:
Reactive<T>
a reactive wrapper object that track changes of the underlying object it is wrapping.
- Create a reactive object:
using RxT;
var searchQuery = new Reactive<string>("");
- Change the state:
searchQuery.Value = "search";
- Track its state changes as an
IObservable<T>
searchQuery
.Subscribe(x => Console.WriteLine($"Search Query: {x}"));
There is also an additional ConcurrentReactive<T>
a thread-safe version of Reactive<T>
.
Computed<T>
a read-only reactive object that track changes of a Reactive<T>
object while applying a custom filter to its underlying IObservable<T>
- Create a computed object from previous
searchQuery
with 500ms debouncing filter
using RxT;
var searchQuery = new Reactive<string>("");
var searchQueryDebounced = searchQuery
.SpawnComputed(obs => obs.Throttle(500));
- Track its state changes as an
IObservable<T>
searchQueryDebounced
.Subscribe(x => Console.WriteLine($"Search Query Debounced: {x}"));
Both Reactive<T>
& Computed<T>
implements the IObservable<T>
interface
Computed<T,R>
same as Computed<T>
but with different type for Value
using RxT;
var searchQuery = new Reactive<string>("");
var searchLength = searchQuery
.SpawnComputed(
// Transform function to apply each time state changes
query => query.Length,
obs => obs.DistinctUntilChanged());
Changing values of nested properties:
changing Reactive<T>.Value
value directly will only trigger state change if T
is a primitive type or string
, nested properties will not trigger any state change.
Solution:
use Reactive<T>.Modify()
method
using RxT;
var pagination = new Reactive<Pagination>(new Pagination()
{
Page = 1,
PageSize = 25,
SortBy = "+createdAt"
});
pagination.Modify((p, triggerChange) =>
{
p.Page = 2;
triggerChange();
});
record Pagination
{
public int Page { get; set; }
public int PageSize { get; set; }
public string SortBy { get; set; }
}
you can also omit triggerChange()
and state change will be triggered automatically
pagination.Modify(p => p.Page = 2);
same thing can be done to Computed<T>
, keep in mind it will change the source Reactive<T>.Value
as it is passed by reference
paginationComputed = pagination.SpawnComputed(obs => obs)
paginationComputed.ModifySource(p => p.Page = 2);
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 (>= 5.0.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.0.0 | 26,472 | 9/10/2022 |
1.0.0-beta | 145 | 9/10/2022 |