SlideShare a Scribd company logo
Reactive Extensions for JavaScript@JimWooleyhttp://www.ThinqLinq.comConsultant
Reactive Framework“Rx is a library for composingasynchronousandevent-based operations using observable collections.”
Reactive Framework“RxJsis a library for composingasynchronousandevent-based operations using observable prototypes.”
Observable Collection - Common Uses
Flavors of RxRxJs
IEnumerator vs. IObserverpublic interface IEnumerator{   object Current { get; }   bool MoveNext();   void Reset();}Blockingpublic interface IObserver<T>{    void OnCompleted();    void OnError(Exception exception);    void OnNext(T value);}
LINQ for Javascript?C# Query Syntaxvar query = from c in Customers                    where c.City == "Chattanooga“                    select c.Name; C# Lambda Syntaxvar query = Customers                    .Where(c => c.City == "Chattanooga")                    .Select(c => c.Name);JavaScriptvar query = Customers                    .Where(function (c) { return c.City === “Chattanooga” ; })                    .Select(function (c) { return c.Name; });
Using Rx to query in Javascriptdemo
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.Create86753098675309
RX.Observable.PrototypeGeneratorFlowQuerySelectLetWhereTakeSkipGroupByDoCatchFinallyOnErrorResumeNextFlowScanDistinctUntilChangedReplaySkipLastTakeLastSubscribeDematerializeAsObservsablePublishStartsWithMergeMergeObservableConcatZipCombineLatestSwitchSelectManyTakeWhileTakeUntilSkipUntilPruneTime       TimeIntervalRemoveIntervalRemoveTimestampBufferWithTimeBufferWithCountThrottleSampleRepeatRetryTimeoutDelay
Factory GeneratorsRx.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);
DemoGenerating Observables
Combining streams
SelectManyvarObservableY = ObservableX.SelectMany(function(x) { SomeGenerator(x); });OxfxfxfxOyOyOyOy
TakeUntiloXoYoX
Observable EventsFirst Class Objects
Standardize event model
Disposable
Supports DI
MockableComposing with Eventsdemo
Asynchronous Service RequestsThrottleBingTranslatorTranslateObservableXTakeUntil
Asynchronous Servicesdemo
Why RxJs?Reuse LINQ knowledge

More Related Content

PDF
RxJS - The Reactive Extensions for JavaScript
PPTX
Reactive Programming and RxJS
PPTX
Intro to RxJS
PDF
My Gentle Introduction to RxJS
PPTX
PDF
Reactive programming using rx java & akka actors - pdx-scala - june 2014
PPTX
RxJS and Reactive Programming - Modern Web UI - May 2015
PDF
SF Front End Developers - Ember + D3
RxJS - The Reactive Extensions for JavaScript
Reactive Programming and RxJS
Intro to RxJS
My Gentle Introduction to RxJS
Reactive programming using rx java & akka actors - pdx-scala - june 2014
RxJS and Reactive Programming - Modern Web UI - May 2015
SF Front End Developers - Ember + D3

What's hot (20)

PPTX
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
PPTX
Intro to Functional Programming with RxJava
PPTX
Introduction to RxJava on Android
PDF
Streams, Streams Everywhere! An Introduction to Rx
PDF
RxJava@Android
PPTX
Reactive
PPTX
Introduction to Reactive programming
PDF
Reactive programming with RxJava
PDF
Building Scalable Stateless Applications with RxJava
PDF
An Introduction to Reactive Cocoa
PDF
The Mayans Lost Guide to RxJava on Android
PDF
Journey into Reactive Streams and Akka Streams
PDF
Reactive programming with Rxjava
PPTX
Till Rohrmann – Fault Tolerance and Job Recovery in Apache Flink
PDF
Gpars - the coolest bits
PDF
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
PPTX
Spring batch in action
PPTX
Going Reactive with Spring 5
PDF
The Future starts with a Promise
ODP
Scala Future & Promises
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
Intro to Functional Programming with RxJava
Introduction to RxJava on Android
Streams, Streams Everywhere! An Introduction to Rx
RxJava@Android
Reactive
Introduction to Reactive programming
Reactive programming with RxJava
Building Scalable Stateless Applications with RxJava
An Introduction to Reactive Cocoa
The Mayans Lost Guide to RxJava on Android
Journey into Reactive Streams and Akka Streams
Reactive programming with Rxjava
Till Rohrmann – Fault Tolerance and Job Recovery in Apache Flink
Gpars - the coolest bits
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
Spring batch in action
Going Reactive with Spring 5
The Future starts with a Promise
Scala Future & Promises
Ad

Viewers also liked (20)

PPTX
Functional Reactive Programming with RxJS
PDF
Add Some Fun to Your Functional Programming With RXJS
PDF
Rethink Async With RXJS
PDF
RxJS Evolved
PDF
RxJS - The Reactive extensions for JavaScript
PDF
FRP with Ractive and RxJS
PDF
ReactiveX-SEA
PDF
Progressive Web Apps
PDF
Programação reativa com RxJS e Angular
PPTX
Reactive programming
PDF
RxJS 5 in Depth
PDF
Functional Reactive Angular 2
PDF
Functional Reactive Programming / Compositional Event Systems
PPTX
Angular2 + rxjs
PPTX
Rxjs ngvikings
PPTX
PPTX
Material Design - do smartphone ao desktop
PDF
WebApps com Web Components
PDF
Polymer and Firebase: Componentizing the Web in Realtime
PDF
Polymer Starter Kit
Functional Reactive Programming with RxJS
Add Some Fun to Your Functional Programming With RXJS
Rethink Async With RXJS
RxJS Evolved
RxJS - The Reactive extensions for JavaScript
FRP with Ractive and RxJS
ReactiveX-SEA
Progressive Web Apps
Programação reativa com RxJS e Angular
Reactive programming
RxJS 5 in Depth
Functional Reactive Angular 2
Functional Reactive Programming / Compositional Event Systems
Angular2 + rxjs
Rxjs ngvikings
Material Design - do smartphone ao desktop
WebApps com Web Components
Polymer and Firebase: Componentizing the Web in Realtime
Polymer Starter Kit
Ad

Similar to Reactive Extensions for JavaScript (20)

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

More from Jim Wooley (8)

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

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPT
Teaching material agriculture food technology
PPTX
Cloud computing and distributed systems.
PDF
KodekX | Application Modernization Development
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
MYSQL Presentation for SQL database connectivity
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation_ Review paper, used for researhc scholars
Per capita expenditure prediction using model stacking based on satellite ima...
Building Integrated photovoltaic BIPV_UPV.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
The AUB Centre for AI in Media Proposal.docx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Teaching material agriculture food technology
Cloud computing and distributed systems.
KodekX | Application Modernization Development
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx

Reactive Extensions for JavaScript