# Rx.NET — Reactive Extensions for .NET > Rx.NET (System.Reactive) brings the observer pattern and LINQ-style query operators to asynchronous and event-based data streams in .NET, enabling composable and declarative async programming. ## Install Save in your project root: # Rx.NET — Reactive Extensions for .NET ## Quick Use ```bash dotnet add package System.Reactive ``` ```csharp using System.Reactive.Linq; var clicks = Observable.FromEventPattern(btn, "Click"); clicks.Throttle(TimeSpan.FromMilliseconds(300)) .Subscribe(e => Console.WriteLine("Clicked!")); ``` ## Introduction Rx.NET is the .NET implementation of Reactive Extensions, a library for composing asynchronous and event-based programs using observable sequences. It provides a rich set of LINQ operators to filter, project, aggregate, and combine streams of data, making complex async workflows easier to reason about and maintain. ## What Rx.NET Does - Models push-based data streams with `IObservable` and `IObserver` - Provides 100+ LINQ-style operators for stream composition (Select, Where, Merge, Zip, Buffer, etc.) - Manages concurrency and scheduling through pluggable schedulers - Bridges events, tasks, and async enumerables into observable sequences - Supports backpressure handling and error recovery operators ## Architecture Overview Rx.NET is built around the `IObservable` / `IObserver` duality to `IEnumerable` / `IEnumerator`. Operators are implemented as extension methods that compose observable pipelines lazily. Schedulers abstract threading and timing, allowing the same pipeline to run on thread pools, UI dispatchers, or test schedulers. The library ships as several NuGet packages: System.Reactive (core), System.Reactive.Linq (operators), and platform-specific bindings. ## Self-Hosting & Configuration - Install via NuGet: `dotnet add package System.Reactive` - Targets .NET Standard 2.0, compatible with .NET Framework 4.7+, .NET 6-9 - No external services or configuration files needed - Choose schedulers for concurrency: `TaskPoolScheduler`, `CurrentThreadScheduler`, `DispatcherScheduler` - Add `System.Reactive.Testing` for unit-testing time-dependent streams with `TestScheduler` ## Key Features - Declarative composition of async event streams with LINQ syntax - Hot and cold observable support for flexible subscription models - Built-in error handling operators: Retry, Catch, OnErrorResumeNext - Time-based operators: Throttle, Debounce, Sample, Delay, Timeout - Subjects for multicasting and bridging imperative and reactive code ## Comparison with Similar Tools - **async/await + IAsyncEnumerable** — pull-based; Rx.NET is push-based with richer temporal operators - **System.Threading.Channels** — bounded producer-consumer; no built-in composition operators - **MediatR** — in-process request/response mediator; Rx.NET handles continuous data streams - **TPL Dataflow** — block-based pipeline; Rx.NET has more composable operator vocabulary - **Akka.NET Streams** — actor-based streaming; heavier runtime, built-in backpressure ## FAQ **Q: When should I use Rx.NET instead of async/await?** A: Use Rx.NET when you need to compose multiple event sources, apply time-based operators, or process continuous streams. For single async operations, async/await is simpler. **Q: Does Rx.NET work with Blazor and MAUI?** A: Yes. The core System.Reactive package targets .NET Standard 2.0 and runs on all modern .NET platforms. **Q: How do I test time-dependent Rx.NET code?** A: Use `TestScheduler` from `System.Reactive.Testing` to advance virtual time and assert on emitted values deterministically. **Q: Is Rx.NET still maintained?** A: Yes. The project moved under the dotnet organization on GitHub and continues to receive updates and community contributions. ## Sources - https://github.com/dotnet/reactive - https://reactivex.io --- Source: https://tokrepo.com/en/workflows/asset-40fde89a Author: AI Open Source