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
2 answers

Momentarily ignore values from Observable when another Observable provides a value

I need to ignore Observable values for a period of time when another Observable provides a value. Currently, my implementation uses a variable to control blocking (or ignoring). bool block = false; var blocker = observable1.Do(_ => block = true ) …
supertopi
  • 3,469
  • 26
  • 38
2
votes
1 answer

Is it rude to trigger OnNext from different threads in Reactive Extensions (Rx)?

When implementing IObserver yourself, you know how well you would cope with a situation where OnNext is invoked from different threads, concurrently or sequentially, but what are the expectations of the built in Reactive Extension primitives when it…
SoftMemes
  • 5,602
  • 4
  • 32
  • 61
2
votes
1 answer

Conditional pairing of two streams - Combine If in Reactive Extensions

I am looking to combine the first two sequences as this Marble diagram depicts In this example different lottery players pick numbers, and the numbers they pick are indicated by the color of the small dot on the first line. When winning numbers…
Cel
  • 6,467
  • 8
  • 75
  • 110
2
votes
1 answer

Generate numbers at random time intervals with rx

How can I generate a list of number with Rx.Net, like 0-100, where each number is generated at a random time? edit: seems like this works public void NonBlocking_event_driven() { var random = new Random(); var ob =…
user3115696
  • 311
  • 2
  • 14
2
votes
1 answer

RxJs -- replay all events after each spurt of events

How do you do it? RxJs is still a mystery to me. I was trying stuff like: filterChanges .delay(400) .replay() .reduce(function(acc,x) { return acc.concat(x) }, []) .subscribe(function(changes) { console.log(changes); ... Or …
Sigfried
  • 2,943
  • 3
  • 31
  • 43
2
votes
1 answer

c# observable interval skips ticks

in my code I need to have a long running timer to start some routine every first second of every minute. I tried to use System.Timers.Timer, but it is not very useful because of timer drift. So I've implemented a timer from Reactive extensions which…
S K
  • 170
  • 8
2
votes
2 answers

How can I modify an IObservable such that I collect characters until there have been no characters for a period of time?

I would like to write an Rx query that takes an IObvservable and produces an IObservable. The strings should be buffered until there have been no characters produced for a specified time. The data source is a serial port from which I…
Tim Long
  • 13,508
  • 19
  • 79
  • 147
2
votes
2 answers

Unit testing with FromAsyncPattern

The Reactive Extensions have a sexy little hook to simplify calling async methods: var func = Observable.FromAsyncPattern( myWcfService.BeginDoStuff, myWcfService.EndDoStuff); func(inData).ObserveOnDispatcher().Subscribe(x…
Andrew Anderson
  • 3,409
  • 22
  • 25
2
votes
3 answers

Force flush count-type Observable.Buffer c#

Building on this question which discusses flushing a time-based buffer: Force flush to Observable.Buffer c#, I'm having difficulty working out how to translate this answer given there to the case where I'm buffering by count, not by time: var…
Benjol
  • 63,995
  • 54
  • 186
  • 268
2
votes
2 answers

In Rx, why does When give me outdated elements

I have a stream with several notification types. One notification type contains information about the current file and is sent continuously. Another type is emitted when the user clicks a button. Both notifications are inside a single stream. When…
Alexander Groß
  • 10,200
  • 1
  • 30
  • 33
2
votes
2 answers

Kotlin extension overhead for Android

It´s a good idea to use kotlin extensions all over the code? I miss a lot the extensions from iOS, but this is a good way to use those kind of things in android? Refering to http://antonioleiva.com/kotlin-android-extension-functions/ Is there a…
Daniel Gomez Rico
  • 15,026
  • 20
  • 92
  • 162
2
votes
1 answer

Combining two time-shifted observables conditionally

I need to combine two observables which usually produce values one after the other. The first sequence (let's call it Seq A) produces more values than the second (Seq B), but usually a bunch of values from the first observable are follewed by one…
Sammy S.
  • 1,280
  • 1
  • 16
  • 31
2
votes
2 answers

How do you use Observable.create in the FSharp.Control.Reactive library?

I'm trying to figure out how to use the Observable.create function in the FSharp.Control.Reactive library but seem to be missing something. The function signature is defined as: ((IObserver<'a> -> unit -> unit) -> IObservable<'a>) I've tried a few…
Andy B
  • 541
  • 2
  • 13
2
votes
3 answers

Is ordering guaranteed by call-order cross multiple Rx Subjects?

in my example below where I have 2 subjects and the _primarySubject is always called before the _secondarySubject is the subscriber guaranteed to receive the primary callback before the secondary callback? Test simple test seems to say yes or is…
CodingHero
  • 2,865
  • 6
  • 29
  • 42
2
votes
1 answer

Observable.FromEvent<> not working with Umbraco ContentService.Published

I'm trying to wire up Umbraco events using Rx: Observable.FromEvent>, PublishEventArgs>( h => ContentService.Published += h, h => ContentService.Published -=…
mnwsmit
  • 1,198
  • 2
  • 15
  • 31