REACTIVE EXTENSIONS
PULL…• Most programming today is based on a “pull” model• Ask a data source for an item, wait for the item to be returned,...
…VS PUSH• The “push” model aims to make our applications less concerned  with the data flow• Our app asks a data source to...
REACTIVE EXTENSIONS (RX)• Some neat baked-in interfaces, extension methods, and static  classes for implementing Pull-base...
IOBSERVABLE<T>• Interface representing a collection that you can “observe”• IDisposable Subscribe(IObserver<Type> observer...
IOBSERVER<T>• Interface representing something that can observe an  observable• void OnNext(T data) – called by observable...
EXAMPLE!• Twitter Firehose API Example
OBSERVABLE STATIC CLASS• IObserable/IObserver are all well and good, but we really  could’ve done that without Rx• Observa...
OBSERVABLE• Example Code!
SCHEDULER• By default, Observable will automatically schedule itself on a  certain thread, by default it uses TaskPool• Yo...
RX AND LINQ• Rx adds a few new LINQ extension methods, as well as uses  the existing ones• Example Code!
OBSERVABLE SUBJECT• Subject is a proxy class you can use to wrap a non-pull system  and create an observable• Implements b...
IQBSERVABLE• Combines LINQ’s Queryable and Rx’s Observable functionality• Queryable – allows you to create a query client ...
Upcoming SlideShare
Loading in...5
×

Reactive Extensions

1,116
-1

Published on

The Reactive Extension library in .NET

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,116
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Reactive Extensions

  1. 1. REACTIVE EXTENSIONS
  2. 2. PULL…• Most programming today is based on a “pull” model• Ask a data source for an item, wait for the item to be returned, and then process it• Our app is active the entire time • makes the request, • waits for the result (usually a blocking operation), • controls the speed at which we process the result
  3. 3. …VS PUSH• The “push” model aims to make our applications less concerned with the data flow• Our app asks a data source to notify us if it has data we can use• The data source is responsible for the notification and sending of data• Our app is free to continue on its way, and is simply notified if there’s new data• AKA Observer Pattern
  4. 4. REACTIVE EXTENSIONS (RX)• Some neat baked-in interfaces, extension methods, and static classes for implementing Pull-based (observable pattern) systems• Originally announced on Nov 17, 2009• Included in .NET v4.0
  5. 5. IOBSERVABLE<T>• Interface representing a collection that you can “observe”• IDisposable Subscribe(IObserver<Type> observer) only interface method
  6. 6. IOBSERVER<T>• Interface representing something that can observe an observable• void OnNext(T data) – called by observable when the next piece of data is ready• void OnError(Exception ex) – called by observable when an error occurs• void OnCompleted() – called by observable when the pull operation has completed
  7. 7. EXAMPLE!• Twitter Firehose API Example
  8. 8. OBSERVABLE STATIC CLASS• IObserable/IObserver are all well and good, but we really could’ve done that without Rx• Observable/Observer provide static methods to create Observables/Observers without class definitions• Provides a whole bunch of options• Separate install (can be installed from NuGet)
  9. 9. OBSERVABLE• Example Code!
  10. 10. SCHEDULER• By default, Observable will automatically schedule itself on a certain thread, by default it uses TaskPool• You can control this by passing in a scheduler • ImmediateScheduler, CurrentThreadScheduler, DispatcherScheduler, NewThreadScheduler, TaskPoolScheduler, ThreadPoolScheduler • Example Code!
  11. 11. RX AND LINQ• Rx adds a few new LINQ extension methods, as well as uses the existing ones• Example Code!
  12. 12. OBSERVABLE SUBJECT• Subject is a proxy class you can use to wrap a non-pull system and create an observable• Implements both IObservable<T> and IObserver<T>• Example Code!
  13. 13. IQBSERVABLE• Combines LINQ’s Queryable and Rx’s Observable functionality• Queryable – allows you to create a query client side using LINQ, and pass that query to a data source (server, database, web service, etc)• Observable – instead of blocking until the data comes back, will just let you know when it gets the data
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×