RxFree 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package RxFree --version 1.1.0
NuGet\Install-Package RxFree -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RxFree" Version="1.1.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RxFree --version 1.1.0
#r "nuget: RxFree, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RxFree as a Cake Addin
#addin nuget:?package=RxFree&version=1.1.0

// Install RxFree as a Cake Tool
#tool nuget:?package=RxFree&version=1.1.0

An ultra-lightweight Rx source-only nuget to avoid depending on the full System.Reactive for IObservable<T> producers.

Version Downloads License

Usage

All of the documentation and samples for Subject<T> and the provided extension methods (i.e. Subscribe overloads) that are officially available for System.Reactive apply to this project as well, since the implementations are heavily based on it (taking them to the bare essentials for source-only inclusion, with Subject<T> being pretty much exactly the same). For example: Using Subjects.

using System;

var subject = new Subject<string>();

subject.Subscribe(x => Console.WriteLine($"Got raw value {x}"));

subject.Where(x => int.TryParse(x, out _))
    .Select(x => int.Parse(x))
    .Subscribe(x => Console.WriteLine($"Got number {x} (squared is {x * x})"));

subject.Where(x => bool.TryParse(x, out var value) && value)
    .Subscribe(x => Console.WriteLine($"Got a boolean True"));

while (Console.ReadLine() is var line && !string.IsNullOrEmpty(line))
    subject.OnNext(line);

Why

For the most part, a producer needs the Subject<T> (read more about using subjects) and maybe the ObservableExtensions that provide Subscribe overloads to provide lambdas instead of an IObserver<T>. Taking the somewhat large and heavy dependency on the full System.Reactive to consume just the basics a reusable library needs is overkill in most cases.

In addition to Subject<T>, typical activities of a producer are to handle disposables and potentially filter/query/convert other observables they consume themselves. So the following simple features are provided:

  • Subject<T>: for producing observable sequences
  • Disposable.Empty and Disposable.Create(Action)
  • CompositeDisposable: allows disposing subscriptions as a group
  • Extension methods for IObservable<T>:
    • Subscribe overloads receiving delegates for onNext, onError and onCompleted
    • Select/Where/OfType LINQ operators

This is what this project provides at the moment, in source form, in your project, as internal classes for your own implementation usage, with no external dependencies. They are not even visible in the project since NuGet provides them automatically to the compiler, embedded into your own assembly, and which you can fully debug as any other code in your project.

Sponsors

sponsored clariusclarius

get mentioned here too!

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

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.1.3 142 1/24/2024
1.1.2 1,457 8/8/2022
1.1.1 692 7/26/2022
1.1.0 879 10/28/2021
1.0.5 637 9/27/2021
1.0.4 459 9/22/2021
1.0.3 279 9/22/2021