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
14
votes
4 answers

Where is System.CoreEx.dll for Rx.NET

This might seem like a silly question, but I downloaded the Reactive Extensions for .NET from here: http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx This simple example is giving me a build error: var test = new[] { 1, 2, 4, 5…
Joel Martinez
  • 46,929
  • 26
  • 130
  • 185
14
votes
5 answers

How to timeout a long running program using rxpython?

Say I have a long running python function that looks something like this? import random import time from rx import Observable def intns(x): y = random.randint(5,10) print(y) print('begin') time.sleep(y) print('end') return…
syllogismos
  • 600
  • 2
  • 15
  • 39
14
votes
1 answer

For Observable, is the subscribe order guaranteed to be the same as the order of notification?

I wonder if, given the following RX code: myObservable.subscribe(obs1) myObservable.subscribe(obs2) ... it is guaranteed that obs1.onNext is called before obs2.onNext PS: From my perspective it's bad practice to write code that relies on the…
vidi
  • 2,056
  • 16
  • 34
14
votes
3 answers

Reactive Extensions seem very slow - am I doing something wrong?

I'm evaluating Rx for a trading platform project that will need to process thousands of messages a second. The existing platform has a complex event routing system (multicast delegates) that responds to these messages and performs a lot of…
Chris Webb
  • 752
  • 7
  • 22
14
votes
1 answer

Is there Rx.NET for .NET Core?

Found https://github.com/Reactive-Extensions/Rx.NET/issues/148, but I could not figure out the bottom line - where is Rx.NET for .NET Core and how to get it? I am using Enterprise Visual Studio 2015 Update 3 with .NET Core installed.
mark
  • 59,016
  • 79
  • 296
  • 580
14
votes
2 answers

Merging two Observables with one taking higher priority

Is it possible to use ReactiveExtensions to achieve the following; Two Observables, one which is "High" priority and the other "Low" Merging both Observables into one, which can then be subscribed to, with intention that this resulting Observable…
Chris McAtackney
  • 5,192
  • 8
  • 45
  • 69
14
votes
1 answer

Should I be calling Dispose on Reactive Extensions (Rx) Subject

I am using the Reactive Extensions (Rx) Subject as a direct replacement for C# events like so: public class MyClass { private Subject subject; public IObservable WhenSomethingHappened { get { return…
Muhammad Rehan Saeed
  • 35,627
  • 39
  • 202
  • 311
14
votes
5 answers

How to create an observable that produces a single value and never completes

I am aware of Observable.Never() as a way to create a sequence that never completes, but is there an extension/clean process for creating an observable that produces a single value and then never completes? Do i go with Observable.Create(...)?…
el2iot2
  • 6,428
  • 7
  • 38
  • 51
14
votes
1 answer

Is Observable.Interval useful for high frequency events?

I'm using Observable.Interval to test how well a particular piece of client/server code performs at different loads. But it seems to have some odd behaviour. Observable.Interval(timespan = 0) produces events as quickly as possible, e.g. 8 million…
ben
  • 1,441
  • 2
  • 16
  • 21
14
votes
2 answers

Requesting a clear, picturesque explanation of Reactive Extensions (RX)?

For a long time now I am trying to wrap my head around RX. And, to be true, I am never sure if I got it - or not. Today, I found an explanation on http://reactive-extensions.github.com/RxJS/ which - in my opinion - is horrible. It says: RxJS is to…
Golo Roden
  • 140,679
  • 96
  • 298
  • 425
14
votes
1 answer

TPL Dataflow and Rx Combined example

I just want to learn both and how to use them together. I understand that they can complement each other I just could not find an example of someone actually doing it.
naeron84
  • 2,955
  • 3
  • 30
  • 37
13
votes
4 answers

Avoiding overlapping OnNext calls in Rx when using SubscribeOn(Scheduler.TaskPool)

I have some code using Rx, called from multiple threads that does: subject.OnNext(value); // where subject is Subject I want the values to be processed in the background, so my subscription is subscription =…
Wilka
  • 28,701
  • 14
  • 75
  • 97
13
votes
2 answers

.net Observable 'ObserveOn' a background thread

I am trying to implement a simple Observer pattern using .net Observable class. I have code that looks like this: Observable.FromEventPattern( Instance.User, "PropertyChanged") .Where(e =>…
user981225
  • 8,762
  • 6
  • 32
  • 41
13
votes
1 answer

How do I provide the latest value of a hot observable on subscribe

I have a hot observable (from an event) that I'm calling DistinctUntilChanged on which will have multiple subscribers who will subscribe at different times after the observable has started running and produced its first value. Subscribers will get…
Bryan Anderson
  • 15,969
  • 8
  • 68
  • 83
13
votes
1 answer

How to get a WinForm synchronization context or schedule on a WinForm thread

I have a winform application, and an observable set up like this: Form form = new Form(); Label lb = new Label(); form.Controls.Add(lb); Observable.Interval(TimeSpan.FromSeconds(1)) .Subscribe(l => lb.Text =…
Boris
  • 5,094
  • 4
  • 45
  • 71