system.reactive

Reactive Framework Hello World

This is an easy program to introduce Reactive Framework. But I want to try the error handler, by modifying the program to be: var cookiePieces = Observable.Range(1, 10); cookiePieces.Subscribe(x => { Console.WriteLine("{0}! {0} pieces of cookie!", x); throw new Exception(); // newly added by myself }, ex => Cons...

Could not load file or assembly 'System.Reactive, Version=1.0.0.0

I get this warning but cannot find an explicit reference to the mentioned assembly. Could not load file or assembly 'System.Reactive, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1b331ac6720247d9' or one of its dependencies. The system cannot find the file specified. Google tells me this is something to do with the Reactive Frame...

How to use Observable.FromEvent with static events?

I am trying to use Reactive Extensions to write code to handle an asynchronous call where both the initiating method and the completed event are static. I can't use var languageSetsLoaded = Observable .FromEvent<LoadLanguageSetsCompletedEventArgs>( LanguageManager, "LanguageSetsLoaded") as LanguageManager is a static class rathe...

Rx - unsubscribing from events

I have an INotifyPropertyChanged object, Foo. I turn Foo into an observable stream of events using Rx's FromEvent method: var myFoo = new Foo(); var eventStream = Observable.FromEvent<PropertyChangedEventArgs>(myFoo, "PropertyChanged"); Now I want to listen for a particular property changed, and if .Progress == 100, unsubscribe: even...

Using reactive extensions to hold onto the most recent event in a series of events until x seconds after most recent event has been received.

I am trying to understand how the following scenario could be implemented using reactive extensions. Other solutions that I have been looking at involve managing a series of timers... something that I am looking to avoid if possible. Scenario A stream of "ActionRequests" occurring. The ActionRequest's streaming in are from different o...

Can this code be refactored by using the reactive framework ?

Hi all, copy paste the following code in new C# console app. class Program { static void Main(string[] args) { var enumerator = new QueuedEnumerator<long>(); var listenerWaitHandle = Listener(enumerator); Publisher(enumerator); listenerWaitHandle.WaitOne(); } private static AutoResetEve...

How would I organize these calls using Reactive Extensions (Rx) in Silverlight?

I have some calls that must execute sequentially. Consider an IService that has a Query and a Load method. The Query gives a list of widgets, and the load provides a "default" widget. Hence, my service looks like this. void IService.Query(Action<IEnumerable<Widget>,Exception> callback); void IService.Load(Action<Widget,Exception> callba...

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 [Tab] and my app would replace the previously typed characters with the elsewhere specifi...

How to use System.Linq.Observable.Throttle()

I have the following code that uses the Observable class from System.Reactive. I'm using the November 2009 Silverlight 3 toolkit. private IObservable<Event<EventArgs>> _ob; private IDisposable _proxy; ... private void Init() { _ob = Observable .FromEvent<EventArgs>( x_Grid, "LayoutUpdated" ) .Throttle( 2000 );...

Examples of IQbservable

I am trying to come up with some good examples of IQbservable usage and thought I'd ask if anyone has used it yet, or has any ideas for how it might be used or abused? EDIT This (IQbservable) is not a typo! (See comments) ...

Rx Need help in writing hierarchy for the classes

I used 101 samples of Rx Framework ( http://rxwiki.wikidot.com/101samples#toc47 ) last example and created a class like below and usage like in the test function. private void Test() { var order = new Order(); order.ObservableOrder.Subscribe( ord => Console.WriteLine("Order progress "), // subscribe to onnext event ...

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 =>...

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...

Is there any way to know when an OnNext has been handled ?

Hi, I have a pipeline setup all using reactive extensions, starting with a stream of values (could arrive any time they want) and then, subscribing to it there are many different "modules" outputting a stream of calculated values, and that stream is also subscribed to by another level of modules who also compute other values. Now at the...

How can I filter the events using Throttle

I'm trying reactive-framework in a win-form. IObservable<IEvent<MouseEventArgs>> mouseMoves = Observable.FromEvent<MouseEventArgs>(this, "MouseMove"); IObservable<IEvent<MouseEventArgs>> mouseDowns = Observable.FromEvent<MouseEventArgs>(this, "MouseDown"); IObservable<IEvent<MouseEventArgs>> mouseUps = Observable.FromEvent<MouseEventArg...

Disposing IDisposable items generated by Observable

I have an Observable<WebResponse> (WebResponse implements IDisposable) responseObservable .Where(webResponse => webResponse.ContentType.StartsWith("text/html")) .Select(webResponse => webResponse.ContentLength) .Run() (Ignore the pointlessness of the query!) so, I'm discarding WebResponse instances without calling Dispose...

RIA Services matching a response to the request

Hey all, I was wondering if someone could provide some advice on the following problem. We are currently developing a Silverlight 4 application based on RIA .NET Services. One of the screens in the application allows users to type in a search string and after 2 seconds of inactivity the request is submitted to our domain service. This i...

Use Rx with typed message broker

I have a typed message broker similar to what Caliburn provides: public interface IMessageBroker { void Publish<T>(T message); IDisposable Subscribe<T>(Action<T> subscriber); } How can I to convert subscriptions to IObservable? I want an extension method, something like this: public static IObservable<T> Subscribe<T>(this IM...