.NET Zone is brought to you in partnership with:

Developer with experience in a variety of different systems and technologies, with a customer focus and balance with business goals. Particularly interested in backend and large scale systems, and also interested in high level architecture, and API design. Always open to feedback in order to keep learning and improving as a professional. Rodrigo is a DZone MVB and is not an employee of DZone and has posted 39 posts at DZone. You can read more from them at their website. View Full User Profile

Reactive Extensions (Rx) For Event-based Programming

  • submit to reddit
One of the nice .NET features I learned recently is called Reactive Extensions. This is a very nice library that allows asynchronous and event-based programs to be used as collections. I found it particularly compelling to learn it as I see more and more code being written in async way and event-driven. However, if you're not so used to this kind of programming, it is hard to wrap your mind around code that makes use of it - and debug and find where issues can be when they arise.

Reactive Extensions moves from a pull-model to a push-model, where instead of having a collection that implements an IEnumerable, you have an IObservable that you subscribe to. Your delegate is then called whenever an event is dispatched by your source. But it's not only that. You can make use of many Linq operators to make your code much simpler.

I'd recommend that you watch the videos on the following page:

Out of these videos, do the workshops and try the challenges. Since they are not ordered on the page above, let me list them in order here:

Finally, another good link is this page with tens of Rx samples:
Published at DZone with permission of Rodrigo De Castro, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)