Reactive Extensions (Rx) For Event-based Programming
Join the DZone community and get the full member experience.
Join For FreeOne 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:
http://msdn.microsoft.com/en-us/data/gg577611
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:
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Introduction
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Observables-versus-Events
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Unified-Programming-Model
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Writing-Queries
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Schedulers
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Event-Processing
Finally, another good link is this page with tens of Rx samples:
http://rxwiki.wikidot.com/101samples
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:
http://msdn.microsoft.com/en-us/data/gg577611
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:
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Introduction
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Observables-versus-Events
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Unified-Programming-Model
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Writing-Queries
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Schedulers
http://channel9.msdn.com/Series/Rx-Workshop/Rx-Workshop-Event-Processing
Finally, another good link is this page with tens of Rx samples:
http://rxwiki.wikidot.com/101samples
Debug (command)
.NET
Links
IT
Library
Event
Operator (extension)
Published at DZone with permission of Rodrigo De Castro, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments