SlideShare una empresa de Scribd logo
1 de 25
Reactive Extensions for JavaScript @JimWooley http://www.ThinqLinq.com Consultant
Reactive Framework “Rx is a library for  composingasynchronousand event-based operations using  observable collections.”
Reactive Framework “RxJsis a library for  composingasynchronousand event-based operations using  observable prototypes.”
Observable Collection - Common Uses
Flavors of Rx RxJs
IEnumerator vs. IObserver public interface IEnumerator {    object Current { get; }    bool MoveNext();    void Reset(); } Blocking public interface IObserver<T> {     void OnCompleted();     void OnError(Exception exception);     void OnNext(T value); }
LINQ for Javascript? C# Query Syntax var query = from c in Customers                     where c.City == "Chattanooga“                     select c.Name;  C# Lambda Syntax var query = Customers                     .Where(c => c.City == "Chattanooga")                     .Select(c => c.Name); JavaScript var query = Customers                     .Where(function (c) { return c.City === “Chattanooga” ; })                     .Select(function (c) { return c.Name; });
Using Rx to query in Javascript demo
Rx Observable Pattern         var obs = ...;         // query?         var sub = obs.Subscribe(             onNext : v => DoSomething(v),             onError : e => HandleError(e),             onCompleted : () => HandleDone);         sub.Dispose();
RxJs Observable Pattern         var obs = ...;        // query?        var sub = obs.Subscribe(             function(v) { DoSomething(v); },             function(e) { HandleError(e); },             function() { HandleDone(); });         sub.Dispose();
var geo = Rx.Observable.Create(function (observer) {  var watchId = navigator.geolocation.watchPosition(         function (pos) { observer.OnNext(pos.coords);  },        function (err) { observer.OnError(err);  }    );         return function () {          navigator.geolocation.clearWatch(watchId);     }; }); var d = geo.Subscribe(function(pos)  {  alert(pos);  }); … d.Dispose(); Observable.Create 8675309 8675309
RX.Observable.Prototype Generator Flow Query Select Let Where Take Skip GroupBy Do Catch Finally OnErrorResumeNext Flow Scan DistinctUntilChanged Replay SkipLast TakeLast Subscribe Dematerialize AsObservsable Publish StartsWith Merge MergeObservable Concat Zip CombineLatest Switch SelectMany TakeWhile TakeUntil SkipUntil Prune Time        TimeInterval RemoveInterval RemoveTimestamp BufferWithTime BufferWithCount Throttle Sample Repeat Retry Timeout Delay
Factory Generators Rx.Observable.Range(0,5); Rx.Observable.Return(“This is a single value”); Rx.Observable.FromArray([“a”, “b”, “c”]); Rx.Observable.Timer(1000,2000); Rx.Observable.Create(function(subscriber) { return  function() { unsub() }}); Rx.Observable.FromDOMEvent(Document.GetElementById(“image”), “mousemove”); Rx.Observable.FromJQuery($(“div,, span”), “click”); $(“div, span”).ToObservable(“click”); Rx.Obsevable.XmlHttpRequest(url);
Demo Generating Observables
Combining streams
SelectMany varObservableY = ObservableX.SelectMany(function(x) { SomeGenerator(x); }); Ox fx fx fx Oy Oy Oy Oy
TakeUntil oX oY oX
Observable Events ,[object Object]
Standardize event model
Disposable
Supports DI
Mockable,[object Object]
Asynchronous Service Requests Throttle BingTranslator Translate ObservableX TakeUntil
Asynchronous Services demo
Why RxJs? ,[object Object]

Más contenido relacionado

La actualidad más candente

Till Rohrmann – Fault Tolerance and Job Recovery in Apache Flink
Till Rohrmann – Fault Tolerance and Job Recovery in Apache FlinkTill Rohrmann – Fault Tolerance and Job Recovery in Apache Flink
Till Rohrmann – Fault Tolerance and Job Recovery in Apache Flink
Flink Forward
 
The Future starts with a Promise
The Future starts with a PromiseThe Future starts with a Promise
The Future starts with a Promise
Alexandru Nedelcu
 

La actualidad más candente (20)

Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
Javantura v3 - Going Reactive with RxJava – Hrvoje CrnjakJavantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
 
Intro to Functional Programming with RxJava
Intro to Functional Programming with RxJavaIntro to Functional Programming with RxJava
Intro to Functional Programming with RxJava
 
Introduction to RxJava on Android
Introduction to RxJava on AndroidIntroduction to RxJava on Android
Introduction to RxJava on Android
 
Streams, Streams Everywhere! An Introduction to Rx
Streams, Streams Everywhere! An Introduction to RxStreams, Streams Everywhere! An Introduction to Rx
Streams, Streams Everywhere! An Introduction to Rx
 
RxJava@Android
RxJava@AndroidRxJava@Android
RxJava@Android
 
Reactive
ReactiveReactive
Reactive
 
Introduction to Reactive programming
Introduction to Reactive programmingIntroduction to Reactive programming
Introduction to Reactive programming
 
Reactive programming with RxJava
Reactive programming with RxJavaReactive programming with RxJava
Reactive programming with RxJava
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
An Introduction to Reactive Cocoa
An Introduction to Reactive CocoaAn Introduction to Reactive Cocoa
An Introduction to Reactive Cocoa
 
The Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on AndroidThe Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on Android
 
Journey into Reactive Streams and Akka Streams
Journey into Reactive Streams and Akka StreamsJourney into Reactive Streams and Akka Streams
Journey into Reactive Streams and Akka Streams
 
Reactive programming with Rxjava
Reactive programming with RxjavaReactive programming with Rxjava
Reactive programming with Rxjava
 
Till Rohrmann – Fault Tolerance and Job Recovery in Apache Flink
Till Rohrmann – Fault Tolerance and Job Recovery in Apache FlinkTill Rohrmann – Fault Tolerance and Job Recovery in Apache Flink
Till Rohrmann – Fault Tolerance and Job Recovery in Apache Flink
 
Gpars - the coolest bits
Gpars - the coolest bitsGpars - the coolest bits
Gpars - the coolest bits
 
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overviewFlink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
 
Spring batch in action
Spring batch in actionSpring batch in action
Spring batch in action
 
Going Reactive with Spring 5
Going Reactive with Spring 5Going Reactive with Spring 5
Going Reactive with Spring 5
 
The Future starts with a Promise
The Future starts with a PromiseThe Future starts with a Promise
The Future starts with a Promise
 
Scala Future & Promises
Scala Future & PromisesScala Future & Promises
Scala Future & Promises
 

Destacado

ReactiveX-SEA
ReactiveX-SEAReactiveX-SEA
ReactiveX-SEA
Yang Yang
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event Systems
Leonardo Borges
 

Destacado (20)

Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
Add Some Fun to Your Functional Programming With RXJS
Add Some Fun to Your Functional Programming With RXJSAdd Some Fun to Your Functional Programming With RXJS
Add Some Fun to Your Functional Programming With RXJS
 
Rethink Async With RXJS
Rethink Async With RXJSRethink Async With RXJS
Rethink Async With RXJS
 
RxJS Evolved
RxJS EvolvedRxJS Evolved
RxJS Evolved
 
RxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScript
 
FRP with Ractive and RxJS
FRP with Ractive and RxJSFRP with Ractive and RxJS
FRP with Ractive and RxJS
 
ReactiveX-SEA
ReactiveX-SEAReactiveX-SEA
ReactiveX-SEA
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
Programação reativa com RxJS e Angular
Programação reativa com RxJS e AngularProgramação reativa com RxJS e Angular
Programação reativa com RxJS e Angular
 
Reactive programming
Reactive programmingReactive programming
Reactive programming
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in Depth
 
Functional Reactive Angular 2
Functional Reactive Angular 2 Functional Reactive Angular 2
Functional Reactive Angular 2
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event Systems
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
 
Rxjs ppt
Rxjs pptRxjs ppt
Rxjs ppt
 
Material Design - do smartphone ao desktop
Material Design - do smartphone ao desktopMaterial Design - do smartphone ao desktop
Material Design - do smartphone ao desktop
 
WebApps com Web Components
WebApps com Web ComponentsWebApps com Web Components
WebApps com Web Components
 
Polymer and Firebase: Componentizing the Web in Realtime
Polymer and Firebase: Componentizing the Web in RealtimePolymer and Firebase: Componentizing the Web in Realtime
Polymer and Firebase: Componentizing the Web in Realtime
 
Polymer Starter Kit
Polymer Starter KitPolymer Starter Kit
Polymer Starter Kit
 

Similar a Reactive Extensions for JavaScript

Ft10 de smet
Ft10 de smetFt10 de smet
Ft10 de smet
nkaluva
 
Reactive extensions itjam
Reactive extensions itjamReactive extensions itjam
Reactive extensions itjam
Ciklum Ukraine
 

Similar a Reactive Extensions for JavaScript (20)

Rxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJavaRxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJava
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJS
 
Ft10 de smet
Ft10 de smetFt10 de smet
Ft10 de smet
 
Reactive Programming with RxJS
Reactive Programming with RxJSReactive Programming with RxJS
Reactive Programming with RxJS
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatient
 
Reactive Extensions (Rx)
Reactive Extensions (Rx)Reactive Extensions (Rx)
Reactive Extensions (Rx)
 
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
 
ReactiveX
ReactiveXReactiveX
ReactiveX
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
Open sourcing the store
Open sourcing the storeOpen sourcing the store
Open sourcing the store
 
Reactive in Android and Beyond Rx
Reactive in Android and Beyond RxReactive in Android and Beyond Rx
Reactive in Android and Beyond Rx
 
How to unit test your React/Redux app
How to unit test your React/Redux appHow to unit test your React/Redux app
How to unit test your React/Redux app
 
Ajax
AjaxAjax
Ajax
 
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorReactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
 
Javascript under the hood
Javascript under the hoodJavascript under the hood
Javascript under the hood
 
Rx java in action
Rx java in actionRx java in action
Rx java in action
 
Ajax Under The Hood
Ajax Under The HoodAjax Under The Hood
Ajax Under The Hood
 
Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018
 
Scala.js for large and complex frontend apps
Scala.js for large and complex frontend appsScala.js for large and complex frontend apps
Scala.js for large and complex frontend apps
 
Reactive extensions itjam
Reactive extensions itjamReactive extensions itjam
Reactive extensions itjam
 

Más de Jim Wooley (8)

Improving code quality with Roslyn analyzers
Improving code quality with Roslyn analyzersImproving code quality with Roslyn analyzers
Improving code quality with Roslyn analyzers
 
Tearing down the //build/ 2016 conference
Tearing down the //build/ 2016 conferenceTearing down the //build/ 2016 conference
Tearing down the //build/ 2016 conference
 
Ssdt wooley
Ssdt wooleySsdt wooley
Ssdt wooley
 
Windows 8 as an Application Integration Hub
Windows 8 as an Application Integration HubWindows 8 as an Application Integration Hub
Windows 8 as an Application Integration Hub
 
Linq tools
Linq toolsLinq tools
Linq tools
 
Entity Framework Migration
Entity Framework MigrationEntity Framework Migration
Entity Framework Migration
 
Dynamic programming in a statically typed world
Dynamic programming in a statically typed worldDynamic programming in a statically typed world
Dynamic programming in a statically typed world
 
Rx forwp7
Rx forwp7Rx forwp7
Rx forwp7
 

Último

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Reactive Extensions for JavaScript

  • 1. Reactive Extensions for JavaScript @JimWooley http://www.ThinqLinq.com Consultant
  • 2. Reactive Framework “Rx is a library for composingasynchronousand event-based operations using observable collections.”
  • 3. Reactive Framework “RxJsis a library for composingasynchronousand event-based operations using observable prototypes.”
  • 6. IEnumerator vs. IObserver public interface IEnumerator {    object Current { get; }    bool MoveNext();    void Reset(); } Blocking public interface IObserver<T> {     void OnCompleted();     void OnError(Exception exception);     void OnNext(T value); }
  • 7. LINQ for Javascript? C# Query Syntax var query = from c in Customers                     where c.City == "Chattanooga“                     select c.Name; C# Lambda Syntax var query = Customers                     .Where(c => c.City == "Chattanooga")                     .Select(c => c.Name); JavaScript var query = Customers                     .Where(function (c) { return c.City === “Chattanooga” ; })                     .Select(function (c) { return c.Name; });
  • 8. Using Rx to query in Javascript demo
  • 9. Rx Observable Pattern         var obs = ...; // query?         var sub = obs.Subscribe(             onNext : v => DoSomething(v),             onError : e => HandleError(e),             onCompleted : () => HandleDone);         sub.Dispose();
  • 10. RxJs Observable Pattern         var obs = ...; // query?        var sub = obs.Subscribe(             function(v) { DoSomething(v); },             function(e) { HandleError(e); },             function() { HandleDone(); });         sub.Dispose();
  • 11. var geo = Rx.Observable.Create(function (observer) { var watchId = navigator.geolocation.watchPosition( function (pos) { observer.OnNext(pos.coords);  },        function (err) { observer.OnError(err);  } );         return function () {          navigator.geolocation.clearWatch(watchId);     }; }); var d = geo.Subscribe(function(pos) { alert(pos); }); … d.Dispose(); Observable.Create 8675309 8675309
  • 12. RX.Observable.Prototype Generator Flow Query Select Let Where Take Skip GroupBy Do Catch Finally OnErrorResumeNext Flow Scan DistinctUntilChanged Replay SkipLast TakeLast Subscribe Dematerialize AsObservsable Publish StartsWith Merge MergeObservable Concat Zip CombineLatest Switch SelectMany TakeWhile TakeUntil SkipUntil Prune Time TimeInterval RemoveInterval RemoveTimestamp BufferWithTime BufferWithCount Throttle Sample Repeat Retry Timeout Delay
  • 13. Factory Generators Rx.Observable.Range(0,5); Rx.Observable.Return(“This is a single value”); Rx.Observable.FromArray([“a”, “b”, “c”]); Rx.Observable.Timer(1000,2000); Rx.Observable.Create(function(subscriber) { return function() { unsub() }}); Rx.Observable.FromDOMEvent(Document.GetElementById(“image”), “mousemove”); Rx.Observable.FromJQuery($(“div,, span”), “click”); $(“div, span”).ToObservable(“click”); Rx.Obsevable.XmlHttpRequest(url);
  • 16. SelectMany varObservableY = ObservableX.SelectMany(function(x) { SomeGenerator(x); }); Ox fx fx fx Oy Oy Oy Oy
  • 18.
  • 22.
  • 23. Asynchronous Service Requests Throttle BingTranslator Translate ObservableX TakeUntil
  • 25.
  • 29. Async time related operations
  • 32.
  • 33.
  • 35. Download at MSDN Data Developer CenterJoin the Community (MSDN forums) http://social.msdn.microsoft.com/Forums/en-US/rx
  • 37. Fill out your Surveys reminder