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

ReactiveUI 7.0, ReactiveCommand, Subscribe never fires?

i'm trying to wrap my head around reactiveUI, which recently updated to 7.0 from 6.5.2, and seems to include some breaking changes regarding ReactiveCommand. EG this used to work: in ViewModel: public ReactiveCommand DoLogin; ... …
101chris
  • 867
  • 2
  • 10
  • 17
2
votes
1 answer

Using Reactive Extensions can I create subscribers to an observable which block until some condition is met or a timeout occurs

Can I/Should I use reactive extensions for this? Basically I have an ESB which I want to monitor for messages (which is essentially where my hot observable sits atop) , and I want to create a bunch of subscribers which will block/pause in the thread…
brumScouse
  • 3,166
  • 1
  • 24
  • 38
2
votes
1 answer

Rx.net - synchronous vs async observers - depends on source?

I'm very new to Rx and trying to wrap my head around it. Haven't read a whole lot but trying to go through a hands on lab first. class Program { static void Main(string[] args) { // one source, produces values with delays …
Raghu
  • 1,140
  • 1
  • 14
  • 22
2
votes
1 answer

Observable.Retry that logs a message?

I have this Observable: var obs = Observable .Defer(() => Observable.FromAsync(asyncFunc)) .Retry() It works, but I would like know when the sequence retries, so I would like to invoke a Logger.Log("Retrying...")…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
2
votes
2 answers

A cache serving updates and new values as "DistinctLatest" and full cache contents upon subscription

I'm trying to implement a cache using a ReplaySubject like follows, but I'm unable to solve the situation using Rx. See code and accompanying tests. The trouble is that the cache drops the newest entries and preserves the oldest. public static class…
Veksi
  • 3,556
  • 3
  • 30
  • 69
2
votes
3 answers

Rx: Ignoring updates caused by Subscribers

I'm having problems figuring out how to do this. I have two instances (source & target) that implement INotifyPropertyChanged and I'm tracking the PropertyChanged event for both. What I want to do is run an action any time source.PropertyChanged is…
Bryan Anderson
  • 15,969
  • 8
  • 68
  • 83
2
votes
2 answers

Rx.Net GroupBy implementation missing element sequence rarely

I am using RX 2.2.5. I have 2 views which load sub orders with _transportService .ObserveSubOrder(parentOrder.OrderId) .SubscribeOn(_backgroundScheduler) .ObserveOn(_uiScheduler) …
MKMohanty
  • 956
  • 7
  • 23
2
votes
3 answers

How to have events separated at least by a given time span?

I want the events of the output sequence to happen as soon as possible, but not within a window of N seconds that starts at the latest event. This is a marble diagram, assuming I want a separation of at least three dashes between events: Input: …
Ignacio Calvo
  • 754
  • 9
  • 22
2
votes
2 answers

Behavior of Observable.Subscribe when used with multiple IEnumerables

I'm attempting to create an IObservable from two arrays (IEnumerables). I'm trying to avoid explicitly iterating over the arrays and calling observer.OnNext. I came across the Observable.Subscribe extension method, which at first glance would…
cristobalito
  • 4,192
  • 1
  • 29
  • 41
2
votes
1 answer

Unsubscribe from dynamic Observables

I'm learning Rx-stuff and I've made a test app, which has a shared counter state and dynamically created counter widgets. Such as you can press add/remove buttons to spawn/destroy a new counter. It works fine, but I don't know how to correctly…
saintcrawler
  • 157
  • 2
  • 8
2
votes
3 answers

Observable.Delay calling Dispose before OnNext is fired

I am having problem understanding how Observable.Delay works and when the Dispose() is meant to be called. Would anyone familiar with Rx be able to help please? The following code snippet: static void Main(string[] args) { var…
Ted
  • 21
  • 2
2
votes
4 answers

How can I route Observable values to different Subscribers?

This is all just pseudo code... Ok here is my scenario, I have an incoming data stream that gets parsed into packets. I have an IObservable Packets Each packet has a Packet ID, i.e. 1, 2, 3, 4 I want to create observables that only receive…
DanUK86
  • 33
  • 6
2
votes
2 answers

C# Rx - ignoring error

I have stream of independent events, that are handled asynchronously with Reactive extension. The handler may fail for whatever reasons, but the stream continues on. However, in Rx, right after an error occurs, it automatically unsubscribes. Is this…
nothrow
  • 15,882
  • 9
  • 57
  • 104
2
votes
2 answers

Throttle but discard results if they come too late

I'm writing a UI where the user can type in a search term and a list get continuously updated offering suggestions. My first though was that the Rx primitive Throttle was a perfect match but it gets me half there. The suggestions take a while to…
buckley
  • 13,690
  • 3
  • 53
  • 61
2
votes
1 answer

Reactive extensions documentation

I encountered an RX method that I have not seen before and went to MSDN to take a look at any documentation that there may be. The method was public static IObservable> CombineLatest (this IEnumerable>…
Flack
  • 5,727
  • 14
  • 69
  • 104