https://github.com/devlooped/rxfree
An ultra-lightweight Rx source-only nuget to avoid depending on the full System.Reactive for IObservable<T> producers
https://github.com/devlooped/rxfree
csharp dotnet reactive rx
Last synced: 6 months ago
JSON representation
An ultra-lightweight Rx source-only nuget to avoid depending on the full System.Reactive for IObservable<T> producers
- Host: GitHub
- URL: https://github.com/devlooped/rxfree
- Owner: devlooped
- License: mit
- Created: 2019-07-19T15:10:34.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-03-18T00:17:27.000Z (7 months ago)
- Last Synced: 2025-03-25T03:34:01.884Z (7 months ago)
- Topics: csharp, dotnet, reactive, rx
- Language: C#
- Homepage: https://clarius.org/RxFree
- Size: 185 KB
- Stars: 32
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: license.txt
Awesome Lists containing this project
README
 RxFree
============[](https://www.nuget.org/packages/RxFree)
[](https://www.nuget.org/packages/RxFree)
[](https://github.com/devlooped/RxFree/blob/main/license.txt)
[](https://github.com/devlooped/RxFree/actions)An ultra-lightweight Rx source-only (C#) nuget to avoid depending on the full
[System.Reactive](https://www.nuget.org/packages/System.Reactive) for `IObservable`
producers.100% dependency-free (source-based) support for library authors exposing IObservable<T> leveraging
Subject<T>, CompositeDisposable, IObservable<T>.Subscribe extension method overloads,
IObservable<T>.Select/Where/OfType LINQ operators, and others.# Usage
All of the documentation and samples for `Subject` 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` being pretty much exactly
the same).
For example: [Using Subjects](https://docs.microsoft.com/en-us/previous-versions/dotnet/reactive-extensions/hh242970(v=vs.103)).```csharp
using System;
using System.Reactive.Subjects;var subject = new Subject();
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);
```This package is a drop-in replacement for `System.Reactive` if you are only using the
most common subset of features in it that are also provided in this project.# Why
For the most part, a producer needs the `Subject` (read more about
[using subjects](https://docs.microsoft.com/en-us/previous-versions/dotnet/reactive-extensions/hh242970(v=vs.103)))
and maybe the `ObservableExtensions` that provide `Subscribe` overloads to provide
lambdas instead of an `IObserver`. Taking the somewhat large and heavy dependency
on the full [System.Reactive](https://www.nuget.org/packages/System.Reactive) to consume
just the basics a reusable library needs is overkill in most cases.In addition to `Subject`, typical activities of a producer invole handling
disposables and potentially filtering/querying/converting other observables they
consume themselves in turn. For that purpose, the following simple features are
included too:- `Subject`: for producing observable sequences
- `Disposable.Empty` and `Disposable.Create(Action)`
- `CompositeDisposable`: allows disposing subscriptions as a group
- Extension methods for `IObservable`:
* `Subscribe` overloads receiving delegates for onNext, onError and onCompleted
* `Select`/`Where`/`OfType` LINQ operatorsThis 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 the package provides them automatically to the compiler, compiled
into your own assembly, and which you can fully debug as any other code in your project.All types are included as `partial` classes, so you can easily add your own code to
them, and make them public if you need to.# Dogfooding
[](https://pkg.kzu.io/index.json)
[](https://github.com/devlooped/RxFree/actions)We also produce CI packages from branches and pull requests so you can dogfood builds as quickly as they are produced.
The CI feed is `https://pkg.kzu.io/index.json`.
The versioning scheme for packages is:
- PR builds: *42.42.42-pr*`[NUMBER]`
- Branch builds: *42.42.42-*`[BRANCH]`.`[COMMITS]`# Sponsors
[](https://github.com/clarius)
[](https://github.com/MFB-Technologies-Inc)
[](https://github.com/torutek-gh)
[](https://github.com/drivenet)
[](https://github.com/Keflon)
[](https://github.com/tbolon)
[](https://github.com/kfrancis)
[](https://github.com/twenzel)
[](https://github.com/unoplatform)
[](https://github.com/dansiegel)
[](https://github.com/rbnswartz)
[](https://github.com/jfoshee)
[](https://github.com/Mrxx99)
[](https://github.com/eajhnsn1)
[](https://github.com/IxTechnologies)
[](https://github.com/davidjenni)
[](https://github.com/Jonathan-Hickey)
[](https://github.com/akunzai)
[](https://github.com/jakobt)
[](https://github.com/tinohager)
[](https://github.com/KenBonny)
[](https://github.com/SimonCropp)
[](https://github.com/agileworks-eu)
[](https://github.com/sorahex)
[](https://github.com/arsdragonfly)
[](https://github.com/vezel-dev)
[](https://github.com/ChilliCream)
[](https://github.com/4OTC)
[](https://github.com/v-limo)
[](https://github.com/jordansjones)
[](https://github.com/DominicSchell)
[](https://github.com/jkingry)[](https://github.com/sponsors/devlooped)
[Learn more about GitHub Sponsors](https://github.com/sponsors)