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

Which Reactive Extensions Code is More Efficient?

Which one would be more efficient, and why? I'm just getting started with RX and trying to understand how to write better code. For example I could do tradesfeed.Where(trade=>trade.Size > 500).Subscribe(x => { Console.WriteLine("big trade: " +…
b4m
  • 21
  • 1
2
votes
2 answers

Splitting Observable into windows

I am looking for Observable.Window like operator with opening window selector As example we can take a sequence of natural numbers. I am wondering how to split this sequence into windows so every new window starts if number is greater than 4 or…
bublegumm
  • 315
  • 1
  • 3
  • 10
2
votes
1 answer

ReactiveCommand.CreateAsync task. How do I cancel the task using a Button?

I have this ReactiveCommand; LoadFileCommand = ReactiveCommand.CreateAsyncTask((_, cancellationToken) => LoadFile(cancellationToken)); I also subscribe to the command subscription = LoadFileCommand.Subscribe(file => OnFileLoaded(file); Now I want…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
2
votes
1 answer

Rx.NET Call function again direct after all it's callbacks

I want to make communication with serial port - get some data. I want to get this data in loop as fast as it's possible. So, i have function GetData() with callback, which draws data on the WPF form. How can I call this GetData function in loop…
Virviil
  • 622
  • 5
  • 14
2
votes
1 answer

Rx - pause Observable.Interval

I am replacing timers on rx's Observable.Interval and I encountered a problem. I don't know how to pause such timer. I don't mean pause subscription, but pausing and resuming time counting. I know how to do this in dirty way, but I would like know…
Lukas
  • 621
  • 2
  • 12
  • 29
2
votes
1 answer

Observables and the Web API

So now that Angular 2 is in beta I have been using observables on the client side and I have been using ASP.NET Core Web API on the server side. My question is if I want to display a value on my website as that value changes I understand how to do…
Irv Lennert
  • 555
  • 5
  • 20
2
votes
1 answer

Combining two Rx stream conditionally

I am trying to implement a scenario using Rx where I have two hot Observables. Stream 1 and Stream 2. Based on data of Stream 1 i need to start Stream 2 or Stop Stream 2. Then combine both the stream data into one using CombineLatest. Below id the…
2
votes
2 answers

Using Rx create a polling request for webservice call

Using Rx in C# I am trying to create a polling request to REST API. The problem which i am facing is that, Observable need to send responses in an order. Means If request A went at X Time and request B went at X + dx time and response of B came…
Balraj Singh
  • 3,381
  • 6
  • 47
  • 82
2
votes
2 answers

Why subscribing an observable in RX.NET by Latest only accepts 1 subscriber?

My goal is to have two subscribers from an observable but I am only interested in the Latest item in the event stream. I want others to be discarded. Consider this like a stock price screen that updates every 1 second and disregarding any…
Onur Gumus
  • 1,389
  • 11
  • 27
2
votes
1 answer

Unit Testing Cache Behaviour of Akavache with TestScheduler

So I'm trying to test caching behaviour in an app that's using Akavache. My test looks like this: using Akavache; using Microsoft.Reactive.Testing; using Moq; using NUnit.Framework; using ReactiveUI.Testing; using System; using…
germi
  • 4,628
  • 1
  • 21
  • 38
2
votes
3 answers

How to make delay in calling textchanged event of textbox in wpf

I have custom control inherited from Textbox. I want to make delay in calling textchanged event. Observable.FromEventPattern( handler => this.TextChanged += handler, …
vishal
  • 596
  • 2
  • 12
  • 31
2
votes
1 answer

Avoiding Converter in Binding

It's really common the scenario where you need to negate a value that comes from the ViewModel. We end up using a Converter like the so called "InverseBoolConverter". My question is: is there a handy way to avoid using a Converter that doesn't…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
2
votes
1 answer

Using Reactive Extension for certain KeyPress sequences?

I am new .. or more precisely.. never used RX so I was wondering whether I can use it for this situation: I want to add a sort of Resharper Live Templates functionality to my app that allows users to enter short sequences of characters followed by a…
Jörg Battermann
  • 4,044
  • 5
  • 42
  • 79
2
votes
1 answer

How to request an item from IObservable?

The original post contained a problem, I managed to solve, introducing a lot of issues with shared mutable state. Now, I'm wondering, if it can be done in a pure functional way. Requests can be processed in a certain order. For each order i there…
2
votes
4 answers

Observable that cyclicly pushes a list of values

I want to create an Observable that keeps pushing a list of values every t seconds. For example, given the {1, 2, 3, 4} subscribers should get this: 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2... class Program { static void Main() { …
SuperJMN
  • 13,110
  • 16
  • 86
  • 185