reactive-extensions

Rx - can/should I replace .NET events with Observables?

Given the benefits of composable events as offered by the Reactive Extensions (Rx) framework, I'm wondering whether my classes should stop pushing .NET events, and instead expose Rx observables. For instance, take the following class using standard .NET events: public class Foo { private int progress; public event EventHandler Pr...

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: " + x.Symbol + " " + x.Size); }); tradesfeed.Where(trade=>trade.Size <= 500).Subscribe(x =>...

Monads and Actors

I've been trying to find anything that discusses when you should favor the use of monads over actors (in concurrency scenarios), but I've found nothing. In particular, I'm wondering about the use of the Reactive Extensions (LINQ to Events) vs. F#'s MailboxProcessor. Please give examples in addition to any philosophical reasoning you migh...

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 Dyer types in the following: var q = from start in mouseDown from delta in mouseM...

Change interval of RX operators?

This might be a stupid question as I'm a bit new to RX :) I'm sampling an event (RX for .Net 4.0): eventAsObservable.Sample(TimeSpan.FromSeconds(1)).Timestamp().Subscribe(x =>Console.WriteLine("testing:" + x.Value.EventArgs.str)); The problem is that the sampling time needs to be able to change on the fly, I guess I could make some pr...

Running sum with Rx

Hi, There must be somebody out there who solved that already. Imagine I have a class that raises periodically an event about the change of a value (e.g. PropertyChanged) That value is nothing else than amount of money. Now, I would like to make use of Rx so that I get the sum of the increasement of that last 10mins. e.g. BufferWithTime...

How can I start an IObservable on a specific time ?

Assuming I use Rx, How can I create an IObservable which will fire an event every 5 seconds how can I make the observable start on a specific date ? How can I make it fire its events on a round date (every midnight ?) ...

IObservable in Silverlight 4

Where can I find this class? I have included the Rx extensions. I have made sure the version I'm compiling to is Silverlight 4. My VS2010 IDE still has no idea what the type IObservable is. I didn't see them in the System.Collections.Generic namespace like this thread suggests http://dotnet.uservoice.com/forums/4325-silverlight-feature-...

Creating a non blocking observable extension method that returns a default item for an empty sequence

Imagine the following linq to observables statement: var x = from result1 in service1.operation() from result2 in service2.operation() from result3 in service3.operation() select DoSomething() x.Subscribe() void Unit DoSomething() { ... } The services all return a cold observable, so they will wait for each ...

Reactive Extensions for .NET (Rx): Take action once all events are completed

As a proof of concept, I want to write "Done" in a text box after a check box has been checked and a key has been pressed in a text box (in either order). I would expect this code to handle this, but it writes Done as soon as either event happens. Thanks for your help. var seq = Observable.FromEvent<EventArgs>(this.checkBox, "CheckedCha...

Should I expose ISubject<T> or IObservable<T> and IObserver<T>?

I have a value that I want users to be able to subscribe to and push to, so internally in my class I'm using Subject<T>. When exposing this value as a property am I best to expose it as a ISubject<T> or is it better to split ISubject<T> into IObserver<T> and IObservable<T>? Option 1: private readonly ISubject<bool> isLightOn = new...

C# 5.0 async/await feature and Rx - Reactive Extensions

I am wondering what do the new C# 5.0 asynchronous features mean for Rx - Reactive Extensions? It seems to be not a replacement but they seem to overlap - Task and IObservable. ...