PowRxVar 0.0.1
See the version list below for details.
dotnet add package PowRxVar --version 0.0.1
NuGet\Install-Package PowRxVar -Version 0.0.1
<PackageReference Include="PowRxVar" Version="0.0.1" />
paket add PowRxVar --version 0.0.1
#r "nuget: PowRxVar, 0.0.1"
// Install PowRxVar as a Cake Addin #addin nuget:?package=PowRxVar&version=0.0.1 // Install PowRxVar as a Cake Tool #tool nuget:?package=PowRxVar&version=0.0.1
PowRxVar
Table of content
Introduction
Provides reactive variables integrated with Rx.Net:
- implement IObservable<T> so can be queried using reactive extensions
- can access and set the current value
- can be combined into other variables (Combine, Switch)
Basics
// Create variables
var a = Var.Make(3);
var b = Var.Make(7);
// Get and set the value
Console.WriteLine($"{a.V}"); // 3
a.V = 4;
// Combine variables
var c = Var.Combine(a, b, (va, vb) => va * 100 + vb);
Console.WriteLine($"{c.V}"); // 407
b.V = 8;
Console.WriteLine($"{c.V}"); // 408
// Dispose a variable
a.Dispose();
var valA = a.V; // Exception
var valB = b.V; // 8
var valC = c.V; // Exception
Basic interfaces
Read only variable IRoVar<T>
interface IRoVar<out T> : IObservable<T>, IRoDispBase
{
// IRoDispBase
// -> can register a callback on disposal & tell if disposed
CancellationToken CancelToken { get; }
bool IsDisposed { get; }
// IObservable<T>
// -> can use it as a normal observable
IDisposable Subscribe(IObserver<T> observer);
// -> can read its value
T V { get; }
}
Read write variable IRwVar<T>
interface IRwVar<T> : IRoVar<T>, IObserver<T>, IRwDispBase
{
// IRwDispBase
// -> inherits from IRoDispBase but can also dispose it
CancellationTokenSource CancelSource { get; }
// IObserver<T>
// -> can be updated by subscribing it to an observable
void OnNext(T value);
void OnCompleted();
void OnError(Exception error);
// -> can read and write its value
T V { get; set; }
}
Note
As IRwVar<T>
inherits from IRoVar<T>
you can naturally use a read write variable in place where a read only one is required.
However, if you want to prevent the calling code from casting it back to an IRwVar<T>
, you can use this extension method:
static IRoBndVar<T> ToReadOnly<T>(this IRwBndVar<T> v);
This is similar to Observable.AsObservable
Bound variables
When binding variables to a UI control, it's sometimes useful to differentiate between updates done by the user through the control (inner) and updates done by the code (outer).
Usage
// Create
var v = Var.MakeBnd(7);
// Set
v.SetInner(3);
v.SetOuter(5);
// Listen to updates
v.WhenInner.Subscribe(...);
v.WhenOuter.Subscribe(...);
// Get the latest value
Console.WriteLine($"{v.V}"); // 5
Similarly to IRoVar<T>
& IRwVar<T>
, bound variables use IRoBndVar<T>
& IRwBndVar<T>
License
MIT
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- System.Reactive (>= 5.0.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on PowRxVar:
Package | Downloads |
---|---|
LINQPadExtras
LINQPad utility functions |
|
PowRxVar.Maybe
Composable reactive variables |
|
PowRxVar.WinForms
Composable reactive variables |
|
PowLINQPad
Reactive control and utilities for LINQPad |
|
ImdbLib
IMDB scraping |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.47 | 378 | 8/19/2023 |
0.0.46 | 234 | 8/9/2023 |
0.0.45 | 204 | 7/9/2023 |
0.0.44 | 222 | 7/2/2023 |
0.0.43 | 207 | 6/23/2023 |
0.0.42 | 208 | 6/23/2023 |
0.0.41 | 206 | 6/23/2023 |
0.0.40 | 207 | 6/20/2023 |
0.0.38 | 208 | 6/19/2023 |
0.0.37 | 220 | 6/17/2023 |
0.0.36 | 205 | 6/17/2023 |
0.0.35 | 219 | 6/17/2023 |
0.0.34 | 220 | 6/16/2023 |
0.0.33 | 201 | 6/13/2023 |
0.0.32 | 203 | 6/13/2023 |
0.0.31 | 208 | 6/13/2023 |
0.0.30 | 209 | 6/13/2023 |
0.0.29 | 222 | 6/13/2023 |
0.0.28 | 198 | 6/13/2023 |
0.0.27 | 220 | 6/12/2023 |
0.0.25 | 269 | 6/5/2023 |
0.0.24 | 216 | 6/5/2023 |
0.0.23 | 212 | 6/3/2023 |
0.0.22 | 214 | 6/3/2023 |
0.0.21 | 224 | 6/2/2023 |
0.0.20 | 219 | 6/2/2023 |
0.0.19 | 216 | 6/2/2023 |
0.0.18 | 219 | 6/1/2023 |
0.0.17 | 284 | 5/28/2023 |
0.0.16 | 274 | 5/28/2023 |
0.0.15 | 284 | 4/24/2023 |
0.0.14 | 364 | 1/3/2023 |
0.0.11 | 400 | 11/26/2022 |
0.0.10 | 365 | 11/24/2022 |
0.0.9 | 378 | 11/18/2022 |
0.0.8 | 357 | 11/18/2022 |
0.0.7 | 409 | 11/15/2022 |
0.0.6 | 423 | 11/15/2022 |
0.0.4 | 591 | 11/13/2022 |
0.0.1 | 412 | 8/13/2022 |