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

How to use Rx Observable with generic EventHandler?

The following code works var mouseTracker = Observable.FromEventPattern(form1, "MouseMove"); //for Form1_MouseMove(object sender, MouseEventArgs e) But how to make the Observable.FromEventPattern to take EventHandler ? Something…
Jeson Martajaya
  • 6,996
  • 7
  • 54
  • 56
2
votes
1 answer

Streaming an IConnectableObservable after processing

I am trying to write a method that takes an IConnectableObservable, does some processing on it and returns a new IConnectableObservable that streams the processed data plus some additional items. The sequence being streamed is finite, but it has…
2
votes
3 answers

Synchronize events in rx in simulations

I have the following streams T1---T2---T3---T4---T5---T6---T7---T8 Q1-Q3-Q7-Q10 I would like to combine them so it looks like this Q1--------Q3------------------Q7----- i,e, only release the event Qi when Ti is released. Is there a simple way to…
2
votes
1 answer

How to use Observable.FromEvent with static events?

I am trying to use Reactive Extensions to write code to handle an asynchronous call where both the initiating method and the completed event are static. I can't use var languageSetsLoaded = Observable …
Steve Crane
  • 4,340
  • 5
  • 40
  • 63
2
votes
2 answers

How to fire RX signal with sliding window based on certain condition

I have a hot observable stream of sensor data. I need an observable signal that fires only when the sensor value has been below 15 for a set period of time. If at anytime the value goes above 15 it should reset the sliding window. I've made it…
batkuip
  • 1,480
  • 3
  • 15
  • 25
2
votes
1 answer

How can I get the current value of a Subject exposed as an IObservable?

I have a User model that has an IObservable property. This property is backed by a BehaviorSubject that is initialized with a certain value. How can I get the current value of the observable, without having to expose another property that…
julealgon
  • 7,072
  • 3
  • 32
  • 77
2
votes
2 answers

Determine and operate on the latest updated sequence in a CombineLatest

I am wondering if there was an existing operator or a certain logic that would allow me to reproduce the behavior of a CombineLatest with 2 source sequences, but with the added ability to determine which of the 2 sequences was modified last. I want…
Phil Gref
  • 987
  • 8
  • 19
2
votes
1 answer

Should Calculation Progress logic reside on Service Layer?

In my WPF applciation, my ViewModel, talks to a ViewModelService, which in turn talks to say for example a CalculationService to retrieve processed data to be presented in the View. I would like for the view to be able to report percentage of…
Karthik Balasubramanian
  • 1,127
  • 4
  • 13
  • 36
2
votes
3 answers

How to hold an exception in an IObservable pipeline and re-throw it at the end?

I have the following method: public IObservable GetWorkItemSource(int maxConcurrentCalls) { return m_namespaceManager .GetNamespaceConnectionInfoSource(true, drainAndDisable: false) .Select(nci =>…
mark
  • 59,016
  • 79
  • 296
  • 580
2
votes
1 answer

Idiomatic way to handle a stream end with RxJS

I need to do a some action when stream ends. What the idiomatic way to do that? Now I use the code bellow: source.subscribe(undefined, undefined, function() { socket.send({type: 'end'}); });
kharandziuk
  • 12,020
  • 17
  • 63
  • 121
2
votes
1 answer

Reactive Extensions - AsyncLock.Wait throws ArgumentNullException

When using Observable.Interval I got a few times the following exception which causes application crash (the exception can be only found in Event Viewer - Error Source: .NET Runtime) Application: RxPlayground.exe Framework Version:…
Pellared
  • 1,242
  • 2
  • 14
  • 29
2
votes
2 answers

What is the Rx.NET way to produce a cancellable observable of file names?

I would like to generate an observable of files, such that the discovery of the files names could be cancelled in any moment. For the sake of this example, the cancellation takes place in 1 second automatically. Here is my current code: class…
mark
  • 59,016
  • 79
  • 296
  • 580
2
votes
2 answers

Observable.Range being repeated?

New to Rx -- I have a sequence that appears to be functioning correctly except for the fact that it appears to repeat. I think I'm missing something around calls to Select() or SelectMany() that triggers the range to re-evaluate. Explanation of…
SeanKilleen
  • 8,809
  • 17
  • 80
  • 133
2
votes
3 answers

ReactiveExtensions: Stop an observable from returning before the tasks it has spun off have finished?

I'm new to Rx .NET but I have a business scenario that I think warrants it. However, I'm still having my trouble wrapping my head around the initial design. The Problem I have a large set of items, let's say 600k. I have a way of pulling these from…
SeanKilleen
  • 8,809
  • 17
  • 80
  • 133
2
votes
0 answers

Why does an empty ReactiveCommand.CreateAsyncObservable() corrupt my Xamarin.Forms ListView, but simple ICommand works?

I have a very simple setup: A ContentPage has a ListView as it's only content. The list supports pull to refresh. It is binding to a command: listView.SetBinding(ListView.RefreshCommandProperty, vm =>…
Krumelur
  • 32,180
  • 27
  • 124
  • 263