rx

using IObservable with unity

I want to use the iobservable pattern to expose a stream of events. The problem is that I'm using unity to create both the observer and the event generator. I would rather not have to new up both of these at application start just so I can start listening for events. Does any one have any suggestions about this? ...

How to get Rx Observable event stream inside MVVM ViewModel

I was just reading Rx HOL NET. Upon finding (example uses Windows Forms): var moves = Observable.FromEvent<MouseEventArgs>(frm, "MouseMove"); I wonder how can I instantiate and pass the reference to moves to ViewModel in some WPF MVVM setup? In my understanding it does make sense to try and filter this stream of data inside ViewModel....

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

Reactive Extensions: Throttle/Sample with varying interval

I have an IObservable that produces values at random intervals and I want to throttle this sequence. One thing I have found out is that the Throttle operator's definition of "throttling" is not the same as mine. Throttle only produces values after the specified interval elapses with silence (it produces the last value seen). I thought t...

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

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

How to manually trigger MouseMove event for a stationary mouse

Hi all, I'm implementing a 'value under cursor' readout for chart contents. Currently I am achieving this using ReactiveExtensions and subscribing to the GetMouseMove event on my chart background Grid: private void SetupMouseover( Grid plotArea) { var mouseMove = from mo in plotArea.GetMouseMove() select new...

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

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 that 'Observable' is not liked by WPF... I have added both reference to: System.CoreEx ...

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

Using Rx to simplify an asynchronous Silverlight web service request

I have written a simplified Silverlight client library for my WCF web service using Rx, however I notice sometimes I'm missing completed events. public IObservable<XElement> GetReport(string reportName) { return from client in Observable.Return(new WebServiceClient()) from request in Observable.ToAsync<string>(client.Get...

Books on Rx and PRISM/CAL + MVVM

Are there any good books that explains Rx, MVVM, PRISM/CAL from ground up? I googled, but could not find anything that covers all these three. ...

What is the difference between the Observer and Subject-Observer patterns

While watching some videos on Channel 9 about the Reactive Extensions for .NET, someone asked whether the Reactive Extensions library is an implementation of the Observer pattern. The presenter then went on to answer by saying that the library is an implementation of the Subject Observer pattern. This leads me to believe that there is po...

Control events into commands and RX

Hi We have some WPF/Silverlight controls we have written using the traditional event architecture (no commands etc.), and want to convert it to MVVM compliant ones. I researched on this subject, and i take it i will have to write commands to wrap the events that i currently have in the control. I would like to design it correctly now so...

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

Rx: EnumerableEx.For() vs Enumerable.SelectMany()

System.Interactive.dll includes a For() method with the following implementation: IEnumerable<TResult> For<TSource, TResult>( IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> resultSelector) { return source.Select<TSource, IEnumerable<TResult>>(resultSelector).Concat<TResult>(); } Am I missing something or ...