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

Reactive framework and WPF conflicts?

I do not have much experiece of WPF, and I consider it as an easier way to markup/coding UI in .net. I have install the lastest Rx release, and play it using Console application without any issue, when I used it in a simple WPF application, it seems…
ccppjava
  • 2,595
  • 3
  • 24
  • 30
2
votes
1 answer

Can I Pair Two Observable Sequences By a Matching Key -- With Repeating Keys?

This question is based on the similarly titled question here, with two differences: I'm matching on multiple keys. No problem. Keys may repeat. Problem. My test code is below. I need the following behavior: A CoordBundle is published as soon…
ket
  • 728
  • 7
  • 22
2
votes
2 answers

Drop any except last sample in observable sequence until consumer is ready

There is a real-time sequence of instrumental observations IObservable. There is also an async consumer function f : S -> Task (with side effects) that may take time to process a value. The function must not be reentered. As soon as it has…
2
votes
1 answer

Reactive 6.5.0 ReactiveCommand after migration

After migrating to ReactiveUI 6.5.0 my tests started failing. The behaviour of Resharper Test Runner is very strange. When I'm running tests one after another - the tests pass but if I run them with big bang approach - Run Unit Tests (we've got…
MistyK
  • 6,055
  • 2
  • 42
  • 76
2
votes
0 answers

Using custom scheduler for audio stream time

In sound processing applications, many events are timed off the audio stream time (which is, in the first approximation, simply a count of consumed samples multiplied by a coefficient), rather than system time, often called wall time in this…
2
votes
2 answers

How do I turn the following class into an IObservable?

I have the following classes namespace TickRateEntity { public struct TickRateData { public double tickrate; } public class TickRate { private TickRateData tickRateData; //etc } } How do change these…
Ivan
  • 7,448
  • 14
  • 69
  • 134
2
votes
1 answer

Why does WhenAnyValue observable trigger on subscription?

I have the following dummy view model: public class DummyViewModel : ReactiveObject { internal DummyViewModel() { ItemChanged.Subscribe(_ => Console.WriteLine()); } public IObservable ItemChanged { get {…
ket
  • 728
  • 7
  • 22
2
votes
1 answer

Can't unsubscribe from Rx

Background I am writing some software that does the following: The user clicks on "start". A task is started that performs some work and launches events to update the GUI. An observable consumes the events from the task, and prints data to a…
Snoop
  • 1,046
  • 1
  • 13
  • 33
2
votes
3 answers

Rx: Are observables "repeatable" like IEnumerable, and if not, how does this code work?

Yesterday I watched the screencast Writing your first Rx Application (on Channel 9) where Wes Dyer shows how to implement Drag 'n' Drop using Reactive Extensions (Rx). Something that I still don't understand: Towards the end of the screencast, Wes…
stakx - no longer contributing
  • 83,039
  • 20
  • 168
  • 268
2
votes
1 answer

Binding an API callback to an RxJava Observable

I'm trying make a reactive application that listens to a network socket on a separate thread for prices and got a bit stumped with how exactly to construct the Observable. Much of the interfaces I have are constrained by the API I am using and…
ScarletPumpernickel
  • 678
  • 1
  • 7
  • 22
2
votes
2 answers

Ignore events if another event fires with Rx

In short Looking for a way to achieve observableOne.SkipIf(observableTwoFiresWithinPeriod) Explanation Let's say I am observing people walking through a door (walkins Observable) and I also have a way to tell if they have a phone (phoneWalkins…
Cel
  • 6,467
  • 8
  • 75
  • 110
2
votes
2 answers

How to use Reactive Extensions for an event bus

I'm having a hard time trying to figure out how to use reactive extensions to create an event bus in C# without the Subject class which I understand is is not recommended. Most of the IEvents are my own but some like mouse & keyboard events will…
Canacourse
  • 1,805
  • 2
  • 20
  • 37
2
votes
1 answer

Reactive (RX) throttle without loss

Before I go write one I thought it would be worth asking: RX has a throttle extension method which discards events if they occur too quickly. So if you asked it to throttle events to 1 per 5 seconds, if you received a event after 0.1second, then a…
Ian
  • 4,885
  • 4
  • 43
  • 65
2
votes
2 answers

How can I replace the EventBus pattern with RxJava presenters?

The Controller + EventBus pattern works very well in Android, but firing events everywhere gets really messy. If a controller gets asks to load the same data multiple times, it's easy to have it start loading the first time, and ignore subsequent…
ZakTaccardi
  • 12,212
  • 15
  • 59
  • 107
2
votes
3 answers

Observable.FromEvent signature

What is the purpose of having such a signature in Observable.FromEvent? For example: var appActivated = Observable.FromEvent( h => Application.Current.Activated += h, h => Application.Current.Activated -= h); In particular, what is h? And why +=,…
Bad
  • 4,967
  • 4
  • 34
  • 50