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

ReactiveExtension that was working on old computer is now failing

I'm using the code from Weak Events in .Net, the easy way to handle monitoring changes to an observable collection. The code has worked without any problems for months. I recently updated to a new computer. After getting everything setup and…
Jason Massey
  • 1,088
  • 10
  • 18
2
votes
1 answer

Mock for RX -construction which process events from mouse

I have the following expression private IObservable GetLeftMouseDown() { return from pattern in Observable.FromEventPattern(_element, "MouseDown") where pattern.EventArgs.ChangedButton ==…
2
votes
2 answers

Keeping track of the completions in a repeating sequence in Rx

Could you please let me know if there's a way of keeping track of the completion of the current repetition in a repeating sequence? My end goal is to keep track of the current count and rate of completed repetitions which I can do once I have the…
Dimitri
  • 23
  • 4
2
votes
0 answers

How to modify the group member for Reactive X (Rx) when DerivedCollectionList is Grouped

I have observableCollection of items, and this collection constantly updates. When the item updates, I would like the group to update as well. I would need to group this collection, for each group, I create a GroupItem class, and store items in…
seekle
  • 228
  • 2
  • 7
2
votes
3 answers

How to get Rx Observable event stream inside MVVM ViewModel

I was just reading Rx HOL NET. Upon finding (example uses Windows Forms): var moves = Observable.FromEvent(frm, "MouseMove"); I wonder how can I instantiate and pass the reference to moves to ViewModel in some WPF MVVM setup? In my…
Tony
  • 1,566
  • 2
  • 15
  • 27
2
votes
2 answers

Using Rx to Pair Up Work with Workers

Being fairly new to Rx, I'm trying to achieve something that seems conceptually simple, but I've been struggling for a day trying to figure out how to achieve it in Rx. I have 2 observables, one is an IObservable and the other is…
Daniel Tabuenca
  • 13,147
  • 3
  • 35
  • 38
2
votes
1 answer

Rx CombineLatest with more than two streams

I need to know when the latest value from 4 observable streams match a predicate. For only two streams, I could use CombineLatest with Where. How would I achieve this with n>2 streams. Thanks. Edit: Answer for what I was trying to achieve void…
Damien Sawyer
  • 5,323
  • 3
  • 44
  • 56
2
votes
1 answer

Rx - Reactive extensions - conditional switch from first Observable to second

I have 2 data sources: online and offline (cached). Both of them returns IObservable of object which contains 2 flags - IsSuccess and IsCached. I would like to get data from online source but only when IsSuccess=true. If this fail I would like to…
Tomasz Pikć
  • 753
  • 5
  • 21
2
votes
1 answer

Is this pattern for subscribing to events okay?

I want to have a logger which is "made available" to my application. My application logs interesting things, and subscribers subscribe to those messages. For example a subscriber might put message in a database, or the windows event log, or a…
Daniel James Bryars
  • 4,429
  • 3
  • 39
  • 57
2
votes
2 answers

Making subject synchronization less painful

I want to synchronize access to a BehaviorSubject, so I'm looking to use Subject.Synchronize. However, I have a couple of pain points with this interface and am wondering whether I'm missing a more agreeable way of doing things. Firstly, I am…
Kent Boogaart
  • 175,602
  • 35
  • 392
  • 393
2
votes
1 answer

Signal Filter with Rx.NET

I'd like to implement a signal filter in Rx.NET which starts with an initial set of coefficients. As time goes by the filter coefficients have to be recalculated from a snapshot of observed data values. Here is a small prototype which shows how it…
Daniel
  • 1,522
  • 1
  • 12
  • 25
2
votes
2 answers

With RX and .Buffer(TimeSpan), how to limit the number of items processed in each batch?

I have the following code: Subject _uiActions = new Subject(); _uiSubscription = _uiActions .Buffer(TimeSpan.FromMilliseconds(200)) .Where(x => x.Any()) .ObserveOnDispatcher() …
Contango
  • 76,540
  • 58
  • 260
  • 305
2
votes
2 answers

Merging multiple streams, keeping ordering and avoiding duplicates

I have a problem that I do not know how to handle beautifully with RX. I have multiple streams that all supposedly contain the same elements However​ each stream may lose messages (UDP is involved) or be late/early compared to others. Each of these…
Remy
  • 23
  • 3
2
votes
0 answers

ReactiveUI - Enable ValidatesOnDataErrors in code behind binding

I'm trying to be consistent in my Views and do all Binding in the code-behind with the IViewFor<> implementation. My bindings are all working great, except for my validation where I've implemented IDataErrorInfo on my ViewModel. Before when I just…
JStew
  • 125
  • 1
  • 6
2
votes
1 answer

F#: What is the relationship of an Add method and an IObserver<>

I have the following code working code that I derived from a Pluralsight video from Mark Seeman. I do not understand how the last line works. let sharpObjectCollection = ConcurrentBag>() let sharpObjectSubject = new…
Phillip Scott Givens
  • 5,256
  • 4
  • 32
  • 54