Questions tagged [system.reactive]

System.Reactive refers to the Reactive Extensions for .NET, also known as Rx. Rx provides developers with a reactive programming model over the generic IObservable interface, as opposed to the traditional imperative programming model or the other reactive programming models that rely strictly on .NET Events or specific APIs.

A brief introduction

system.reactive refers to the Reactive Extensions (Rx), a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. System.Reactive is the root namespace used through the library. Using Rx, developers represent asychronous data streams using LINQ operators, and parameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, Rx = Observables + LINQ + Schedulers.

Whether you are authoring a traditional desktop or web-based application, you have to deal with asynchronous and event-based programming from time to time. Desktop applications have I/O operations and computationally expensive tasks that might take a long time to complete and potentially block other active threads. Furthermore, handling exceptions, cancellation, and synchronization is difficult and error-prone.

Using Rx, you can represent multiple asynchronous data streams (that come from diverse sources, e.g., stock quote, tweets, computer events, web service requests, etc., and subscribe to the event stream using the IObserver<T> interface. The IObservable<T> interface notifies the subscribed IObserver<T> interface whenever an event occurs.

Because observable sequences are data streams, you can query them using standard LINQ query operators implemented by the Observable extension methods. Thus you can filter, project, aggregate, compose and perform time-based operations on multiple events easily by using these standard LINQ operators. In addition, there are a number of other reactive stream specific operators that allow powerful queries to be written. Cancellation, exceptions, and synchronization are also handled gracefully by using the extension methods provided by Rx.

Rx complements and interoperates smoothly with both synchronous data streams (IEnumerable<T>) and single-value asynchronous computations (Task<T>).

Source and further information

The project is actively developed by Microsoft Open Technologies, Inc., in collaboration with a community of open source developers. The source code is hosted on github here.

Additional documentation, video, tutorials and hands-on-labs are available on MSDN, and help and discussions the Rx Forums.

ReactiveX has been ported to many platforms, and information about supported platforms and links to platform specific implementations can be found here.

Related tags

3422 questions
2
votes
1 answer

Rx .NET: Filter observable until task is done

I´m learning Rx for .NET and a colleague send me a simple example to start with but there is something ugly I don't like. The code: using System; using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using…
jlvaquero
  • 8,571
  • 1
  • 29
  • 45
2
votes
2 answers

Integration with event where the delegate has more than one argument and there are no EventArgs

There appears to be no overload of the FromEvent or FromEventPattern methods that will convert into an IObservable an event with the type TDelegate only where there is more than one parameter and there is no EventArgs. For e.g. it appears that we…
Water Cooler v2
  • 32,724
  • 54
  • 166
  • 336
2
votes
1 answer

Creating a non blocking observable extension method that returns a default item for an empty sequence

Imagine the following linq to observables statement: var x = from result1 in service1.operation() from result2 in service2.operation() from result3 in service3.operation() select DoSomething() x.Subscribe() void Unit…
Max
  • 43
  • 4
2
votes
1 answer

How to match events in two causal streams to detect excessive lagging

I have two hot observables, which are respectively a stream Q of requests to a network server, and a stream R of replies from the server. The replies are always delivered in the order of requests, and every request is going to receive exactly one…
2
votes
3 answers

How do I create an IObservable that returns a value every -n- seconds without skipping any

This below example was my attempt at doing this: var source = Observable.Sample( Observable.Range(1, int.MaxValue), TimeSpan.FromSeconds(2)); But when I .Subscribe() to that Observable and output it to the console, it shows a sequence…
ZeroBugBounce
  • 3,652
  • 3
  • 31
  • 40
2
votes
1 answer

Xamarin Forms: For what kind of projects is Reactive UI preferable?

I want to know, for which kind of projects can we use ReactiveUI mvvm framework. I know FreshMvvm can pretty much be used for most of the projects but I want to know is there any specific scenarios where its beneficial to use Reactive UI? I am not…
TheDeveloper
  • 1,127
  • 1
  • 18
  • 55
2
votes
1 answer

Why the following trivial Rx.NET does not print any numbers?

using System; using System.Reactive; using System.Reactive.Linq; using System.Reactive.Subjects; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { public static void Main() { …
mark
  • 59,016
  • 79
  • 296
  • 580
2
votes
1 answer

Have they removed the Interval and Timer operators in Rx 3.0?

I can't find the Interval operator and the Timer operator in Rx 3.0. Have these been removed? I installed the System.Reactive NuGet package into my console application in Visual Studio 2015 and now I do not see them. Please see the picture…
Water Cooler v2
  • 32,724
  • 54
  • 166
  • 336
2
votes
1 answer

Reactive Extensions: Creating a pipeline with Rx that works with files

I have a process pipeline with three steps: video to images: I have a video that is converted to still images (frames) frames to zip file: When all the frames in a video have been processed, I should create a Zip File with them. zip file => Upload…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
2
votes
3 answers

Prepend Task to IObservable (symmetry of Finally)

I want to send a start pulse to my server when the first client connects, and a finish pulse when the last one disconnects. public class MyAdapter : IObservable { IObservable MyObservable = BuildMyObservable() …
shannon
  • 8,664
  • 5
  • 44
  • 74
2
votes
1 answer

What is the meaning of opening and closing boundaries with regard to operators such as Buffer?

I do not understand the overloads of the Buffer operator that require an opening or closing boundary. The overloads I am refering to are: public static IObservable> Buffer(this IObservable source,…
Water Cooler v2
  • 32,724
  • 54
  • 166
  • 336
2
votes
1 answer

how to force ObserveOn() on calling thread?

I have a reactiveui/rx app. Currently, I'm developing it's desktop part, so it's a wpf application. I would like to create each window in its separate thread, because of performance reasons. That's why I need ObserveOn to be run on a current…
Mezk Erei
  • 65
  • 6
2
votes
2 answers

Merging an IObservable and IObservable to one observable that OnErrors when there is an exception

I'm trying to create a single Observable which OnNext stream comes from one observable and which OnError stream comes from another observable. The reason why I'm doing this is because I'm trying to wrap a class that is outside of my control and uses…
Roy T.
  • 9,429
  • 2
  • 48
  • 70
2
votes
1 answer

C# Reactive Extensions - Memory management and the Distinct operator

Example code : public static IObservable ObserveOrders(this IProxy proxy,IEqualityComparer distinctPerDayComparer ) { return Observable.FromEvent(ev => proxy.OrderUpdated += ev,ev => proxy.OrderUpdated -= ev) …
eran otzap
  • 12,293
  • 20
  • 84
  • 139
2
votes
1 answer

RxJava: wait another observable result

How to wait another observable result while transforming the current one? I have a list of user ids (userIdsList), and I should convert them to a map. In map key is represented by userId and value is boolean, which indicates if userId containsin…
VB_
  • 45,112
  • 42
  • 145
  • 293