SlideShare uma empresa Scribd logo
1 de 13
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,
  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
…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
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
IOBSERVABLE<T>
• Interface representing a collection that you can “observe”
• IDisposable Subscribe(IObserver<Type> observer)
  only interface method
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
EXAMPLE!
• Twitter Firehose API Example
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)
OBSERVABLE
• Example Code!
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!
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 both IObservable<T> and IObserver<T>
• Example Code!
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

Mais conteúdo relacionado

Mais procurados

"Walk in a distributed systems park with Orleans" Евгений Бобров
"Walk in a distributed systems park with Orleans" Евгений Бобров"Walk in a distributed systems park with Orleans" Евгений Бобров
"Walk in a distributed systems park with Orleans" Евгений Бобров
Fwdays
 
Active Cloud DB at CloudComp '10
Active Cloud DB at CloudComp '10Active Cloud DB at CloudComp '10
Active Cloud DB at CloudComp '10
Chris Bunch
 

Mais procurados (20)

Project Orleans - Actor Model framework
Project Orleans - Actor Model frameworkProject Orleans - Actor Model framework
Project Orleans - Actor Model framework
 
A Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft OrleansA Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft Orleans
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
 
"Walk in a distributed systems park with Orleans" Евгений Бобров
"Walk in a distributed systems park with Orleans" Евгений Бобров"Walk in a distributed systems park with Orleans" Евгений Бобров
"Walk in a distributed systems park with Orleans" Евгений Бобров
 
Massively Scaleable .NET Web Services with Project Orleans
Massively Scaleable .NET Web Services with Project OrleansMassively Scaleable .NET Web Services with Project Orleans
Massively Scaleable .NET Web Services with Project Orleans
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminar
 
What's new in Solr 5.0
What's new in Solr 5.0What's new in Solr 5.0
What's new in Solr 5.0
 
Lecture: MetaLinks
Lecture: MetaLinksLecture: MetaLinks
Lecture: MetaLinks
 
OSMC 2021 | Monitoring Open Source Hardware
OSMC 2021 | Monitoring Open Source HardwareOSMC 2021 | Monitoring Open Source Hardware
OSMC 2021 | Monitoring Open Source Hardware
 
Project Reactor By Example
Project Reactor By ExampleProject Reactor By Example
Project Reactor By Example
 
Ease of use in Apache Solr
Ease of use in Apache SolrEase of use in Apache Solr
Ease of use in Apache Solr
 
Introduction to Akka
Introduction to AkkaIntroduction to Akka
Introduction to Akka
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
Active Cloud DB at CloudComp '10
Active Cloud DB at CloudComp '10Active Cloud DB at CloudComp '10
Active Cloud DB at CloudComp '10
 
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksLecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinks
 
Apache Solr 5.0 and beyond
Apache Solr 5.0 and beyondApache Solr 5.0 and beyond
Apache Solr 5.0 and beyond
 
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksVUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
 
Introduction to reactive programming
Introduction to reactive programmingIntroduction to reactive programming
Introduction to reactive programming
 
AppScale + Neptune @ HPCDB
AppScale + Neptune @ HPCDBAppScale + Neptune @ HPCDB
AppScale + Neptune @ HPCDB
 

Semelhante a Reactive Extensions

Lessons learned from building Demand Side Platform
Lessons learned from building Demand Side PlatformLessons learned from building Demand Side Platform
Lessons learned from building Demand Side Platform
bbogacki
 

Semelhante a Reactive Extensions (20)

SensorThings API webinar-#4-Connect Your Sensor
SensorThings API webinar-#4-Connect Your SensorSensorThings API webinar-#4-Connect Your Sensor
SensorThings API webinar-#4-Connect Your Sensor
 
Getting a Neural Network Up and Running with OpenLab
Getting a Neural Network Up and Running with OpenLabGetting a Neural Network Up and Running with OpenLab
Getting a Neural Network Up and Running with OpenLab
 
Apereo OAE - Bootcamp
Apereo OAE - BootcampApereo OAE - Bootcamp
Apereo OAE - Bootcamp
 
we45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Pythonwe45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Python
 
Data Pipelines with Python - NWA TechFest 2017
Data Pipelines with Python - NWA TechFest 2017Data Pipelines with Python - NWA TechFest 2017
Data Pipelines with Python - NWA TechFest 2017
 
Openstack - An introduction/Installation - Presented at Dr Dobb's conference...
 Openstack - An introduction/Installation - Presented at Dr Dobb's conference... Openstack - An introduction/Installation - Presented at Dr Dobb's conference...
Openstack - An introduction/Installation - Presented at Dr Dobb's conference...
 
Oct meetup open stack 101 clean
Oct meetup open stack 101   cleanOct meetup open stack 101   clean
Oct meetup open stack 101 clean
 
Aspect j introduction for non-programmers
Aspect j introduction for non-programmersAspect j introduction for non-programmers
Aspect j introduction for non-programmers
 
Testing Below the Application
Testing Below the ApplicationTesting Below the Application
Testing Below the Application
 
Lessons learned from building Demand Side Platform
Lessons learned from building Demand Side PlatformLessons learned from building Demand Side Platform
Lessons learned from building Demand Side Platform
 
Workflow Engines for Hadoop
Workflow Engines for HadoopWorkflow Engines for Hadoop
Workflow Engines for Hadoop
 
Consolidating MLOps at One of Europe’s Biggest Airports
Consolidating MLOps at One of Europe’s Biggest AirportsConsolidating MLOps at One of Europe’s Biggest Airports
Consolidating MLOps at One of Europe’s Biggest Airports
 
Jose Luis Soria - XP2014 - Designing a Release Pipeline
Jose Luis Soria - XP2014 - Designing a Release PipelineJose Luis Soria - XP2014 - Designing a Release Pipeline
Jose Luis Soria - XP2014 - Designing a Release Pipeline
 
Basic buffer overflow part1
Basic buffer overflow part1Basic buffer overflow part1
Basic buffer overflow part1
 
Laravel ppt
Laravel pptLaravel ppt
Laravel ppt
 
ElasticSearch as (only) datastore
ElasticSearch as (only) datastoreElasticSearch as (only) datastore
ElasticSearch as (only) datastore
 
Open stack monitoring with minimal effort
Open stack monitoring with minimal effortOpen stack monitoring with minimal effort
Open stack monitoring with minimal effort
 
Sanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticiansSanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticians
 
Flexible compute
Flexible computeFlexible compute
Flexible compute
 
Mini-Training: NancyFX
Mini-Training: NancyFXMini-Training: NancyFX
Mini-Training: NancyFX
 

Mais de RTigger

Async in .NET
Async in .NETAsync in .NET
Async in .NET
RTigger
 

Mais de RTigger (20)

You Can't Buy Agile
You Can't Buy AgileYou Can't Buy Agile
You Can't Buy Agile
 
Caching up is hard to do: Improving your Web Services' Performance
Caching up is hard to do: Improving your Web Services' PerformanceCaching up is hard to do: Improving your Web Services' Performance
Caching up is hard to do: Improving your Web Services' Performance
 
Ready, set, go! An introduction to the Go programming language
Ready, set, go! An introduction to the Go programming languageReady, set, go! An introduction to the Go programming language
Ready, set, go! An introduction to the Go programming language
 
Open source web services
Open source web servicesOpen source web services
Open source web services
 
How to hire a hacker
How to hire a hackerHow to hire a hacker
How to hire a hacker
 
Windows 8 programming with html and java script
Windows 8 programming with html and java scriptWindows 8 programming with html and java script
Windows 8 programming with html and java script
 
Open regina
Open reginaOpen regina
Open regina
 
Single page apps and the web of tomorrow
Single page apps and the web of tomorrowSingle page apps and the web of tomorrow
Single page apps and the web of tomorrow
 
Async in .NET
Async in .NETAsync in .NET
Async in .NET
 
Give your web apps some backbone
Give your web apps some backboneGive your web apps some backbone
Give your web apps some backbone
 
Hackers, hackathons, and you
Hackers, hackathons, and youHackers, hackathons, and you
Hackers, hackathons, and you
 
AJAX, JSON, and Client-Side Templates
AJAX, JSON, and Client-Side TemplatesAJAX, JSON, and Client-Side Templates
AJAX, JSON, and Client-Side Templates
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
 
Parallel Processing
Parallel ProcessingParallel Processing
Parallel Processing
 
Node.js
Node.jsNode.js
Node.js
 
Sql vs NoSQL
Sql vs NoSQLSql vs NoSQL
Sql vs NoSQL
 
Git’in Jiggy With Git
Git’in Jiggy With GitGit’in Jiggy With Git
Git’in Jiggy With Git
 
What The F#
What The F#What The F#
What The F#
 
Web Services
Web ServicesWeb Services
Web Services
 
Total Engagement
Total EngagementTotal Engagement
Total Engagement
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Reactive Extensions

  • 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. …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. 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. IOBSERVABLE<T> • Interface representing a collection that you can “observe” • IDisposable Subscribe(IObserver<Type> observer) only interface method
  • 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
  • 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)
  • 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. RX AND LINQ • Rx adds a few new LINQ extension methods, as well as uses the existing ones • Example Code!
  • 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. 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