Paul Using Rx; 8 November 2014 Raleigh Code Camp.

Slides:



Advertisements
Similar presentations
Reactive Extension to .NET
Advertisements

Slides license: Creative Commons Attribution Non-Commercial Share Alike See
Grade 6 Hopewell Elementary You will read each slide, then try to think of the answer. When you think you know the answer, click ONCE on the mouse.
An Introduction to the Reactive Extensions Ivan Towlson Mindscape.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 12 th -13 th Lecture Pavel Ježek.
Bing it on, Reactive Extensions Building a quick search app from scratch in WPF with Rx and Bing.com.
How to be a C# ninja in 10 easy steps. Benjamin Day.
Work With Skeleton Data
Introduction to Model-View-Controller (MVC) Web Programming with TurboGears Leif Oppermann,
Rx Framework Reactive Extensions for.Net and JavaScript Andrea Nasoni & Diego Guidi.
Lecture 3 IAT 800. Sept 15, Fall 2006IAT 8002 Suggestions on learning to program  Spend a lot of time fiddling around with code –Programming is something.
Iterator Pattern Dr. Neal CIS 480. Iterator An iterator pattern can be used when one class is a collection of things and would like to provide a standardized.
Curing Your Event Processing Blues with Reactive Extensions (Rx)
Page 1 | Microsoft Work With Color Data Kinect for Windows Video Courses Jan 2013.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Intro to Android Programming George Nychis Srinivasan Seshan.
Hot Tuna CROSS PLATFORM DEVELOPMENT WITH.NET, XAMARIN AND MVVMCROSS.
EEC-492/592 Kinect Application Development Lecture 10 Wenbing Zhao
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA Prof. Dr. Paulo Brasko Ferreira Fall 2014.
Eric Vogel Software Developer A.J. Boggs & Company.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
LINQ, Take Two Realizing the LINQ to Everything Dream Bart J.F. De Smet Senior Software Development Engineer Microsoft Corporation.
Introduction to Mobile Programming. Slide 2 Overview Fundamentally, it all works the same way You get the SDK for the device (Droid, Windows, Apple) You.
An Introduction to Silverlight Matt Harrington Developer Evangelist, Microsoft October 20, 2011.
Virtual techdays INDIA │ Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri.
Reactive Extensions Ye olde introduction and walk-through, with plenty o’ code.
Web Services Week 2 Aims: Getting started with creating simple C# applications within Visual Studio.NET Objectives: –An introduction to the syntax of C#.NET.
Lecture 19 Web Application Frameworks Boriana Koleva Room: C54
Putting it all together: LINQ as an Example. The Problem: SQL in Code Programs often connect to database servers. Database servers only “speak” SQL. Programs.
Monads Steve Goguen. About Me Web Developer for Allied Building Supply  ASP.NET, SQL Server, LINQ, etc. Website:
Drupal Commerce Better than Uber Andrew Root: druroot.
Reactive Extensions (Rx) Explained Presenter: Kevin Grossnicklaus August 5 th, 2011.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
How to be a C# ninja in 10 easy steps Benjamin Day.
Jim Ng 15/1/2014 CENG4480 TUTORIAL 1. ABOUT ME Current MPhil Student supervised by Prof. Mak You can find me at Rm116 in SHB
Please visit m.ausalgo.com on your device and sign inm.ausalgo.com.
1 Lecture 22 Reactive Programming with Rx Duality between Push and Pull models, Iterable vs. Observable. Composing two asynchronous services. Ras Bodik.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Inside LINQ to Objects How LINQ to Objects work Inside LINQ1.
PerlNET: The Camel Talks.NET Jan Dubois The Perl Conference 6 San Diego, July 26 th 2002.
EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 8 Wenbing Zhao
CIS 200 Test 01 Review. Built-In Types Properties  Exposed “Variables” or accessible values of an object  Can have access controlled via scope modifiers.
Instructions Go to the shared area and open a file Go to -> S:\ICT\My Teacher\Mr Crossan\Year 7\Catch the Clown Open the Catch the Clown file by double.
Building Robust, Maintainable Coded UI Tests with Visual Studio 2010 Brian Keller Sr. Technical Evangelist – Visual Studio ALM
Yingcai Xiao Programming and Debugging in Unity Yingcai Xiao.
Expressive Intelligence Studio // Center for Games and Playable Media // Unity Pro John Murray Expressive.
TEARING THE DOWN ing Jim Wooley Jim Wooley
In Windows 8 Store Applications
Outline Introduction Programming in eclipse Debugging in eclipse
Outline Introduction Programming in eclipse Debugging in eclipse
Programming and Debugging
CIS 200 Test 01 Review.
WPF AKEEL AHMED.
EEC-693/793 Applied Computer Vision with Depth Cameras
Advanced Topics in Concurrency and Reactive Programming: ReactiveX
EEC-693/793 Applied Computer Vision with Depth Cameras
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Programming and Debugging
DEV422 Becoming a C# Time Lord Joe Albahari 2/5/ :46 AM
An Introduction to Computers and Visual Basic
EEC-693/793 Applied Computer Vision with Depth Cameras
CS5220 Advanced Topics in Web Programming More Node.js
EEC-693/793 Applied Computer Vision with Depth Cameras
Elizabeth Liner Lab of Things.
Server & Tools Business
CS5220 Advanced Topics in Web Programming More Node.js
Web Application Development Using PHP
Presentation transcript:

Paul Using Rx; 8 November 2014 Raleigh Code Camp

Show Accelerometer in Action (Demo) Explanation of Reactive Extensions Explanation of Accelerometer Deep Dive into Some Code Today’s Outline try{ Paul Using Rx; 8 November 2014 Raleigh Code Camp

Switch (AudienceInterest as Pivot) Case Questions: Case WhyIsRxBetterThanEvents: Case WhereToUseRx: Case MoreRxExamples: Case WhatLanguagesHaveAnRxImplementation: Case How2HandleNoise: Case MathsOfAccelerometer : Case WhatsNextInDevelopment: Today’s Outline Paul Using Rx; 8 November 2014 Raleigh Code Camp

Catch(FailedPresentationException e) { PaulSingsAcapella(Song[“Ill Be Watching You”]); } Finally { Resources On Rx; } Return new WannaTryRxMyself(ref Boss); Today’s Outline } Paul Using Rx; 8 November 2014 Raleigh Code Camp

Show Accelerometer in Action (Demo) Explanation of Reactive Extensions Explanation of Accelerometer Deep Dive into Some Code Today’s Outline try{ Paul Using Rx; 8 November 2014 Raleigh Code Camp

Show Accelerometer in Action (Demo) Explanation of Reactive Extensions Explanation of Accelerometer Deep Dive into Some Code Today’s Outline try{ Paul Using Rx; 8 November 2014 Raleigh Code Camp

Show Accelerometer in Action (Demo) Explanation of Reactive Extensions Explanation of Accelerometer Deep Dive into Some Code Today’s Outline try{ Paul Using Rx; 8 November 2014 Raleigh Code Camp

LINQ to Events This means: You can use all the benefits of LINQ Sophisticated Query Methods Function Composition Add your own Extension Method It makes Events be 1 st Class Objects What is Reactive Extensions? Paul Using Rx; 8 November 2014 Raleigh Code Camp

Implementation of the Observer Pattern What is Reactive Extensions? Paul Using Rx; 8 November 2014 Raleigh Code Camp Image Source:

The Mathematical Dual of IEnumerable /IEnumerator What is the Mathematical Dual? Any maths concept which is the reverse of its dual Subtraction is the Dual of Addition Boolean Or || is the Dual of And && Contravariance is the Dual of Covariance What is Reactive Extensions? Paul Using Rx; 8 November 2014 Raleigh Code Camp

Whereas IEnumerable/IEnumerator is consumer-pull-based IEnumerable is the box of blocks IEnumerator is the 3-year-old child pulling blocks out of it Rx is producer-push-based _____________is the pitching machine _____________is the batter observing it What is Reactive Extensions? Paul Using Rx; 8 November 2014 Raleigh Code Camp IObservable IObserver

I see IEnumberable all over the place, but I almost never see IEnumerator. If they’re paired, why don’t I use IEnumerator more? Hey Wait A Minute Paul Using Rx; 8 November 2014 Raleigh Code Camp You do. This: Var enumerator = enumerable.GetEnumerator(); While(enumerator.MoveNext()) { var item = enumerator.Current; item.DoSomething(); } is the same as this: foreach(var item in enumerable) { item.DoSomething(); }

What is Reactive Extensions? Paul Using Rx; 8 November 2014 Raleigh Code Camp Dual-View Comparison of Producer Interfaces Producers Pull-Pattern Producer Push-Pattern Producer Interface Name IEnumerable IObservable InitiationIEnumerator GetEnumerator(); IDisposable Subscribe(IObserver)

What is Reactive Extensions? Paul Using Rx; 8 November 2014 Raleigh Code Camp Dual-View Comparison of Consumer Interfaces Consumers Pull-Pattern Consumer Push-Pattern Consumer InterfaceIEnumerator IObserver Get ItemMoveNext() == true item = enum.Current; OnNext(T item)

What is Reactive Extensions? Paul Using Rx; 8 November 2014 Raleigh Code Camp Dual-View Comparison of Consumer Interfaces Consumers Pull-Pattern Consumer Push-Pattern Consumer Terminate MoveNext() == falsevoid OnCompleted() Handle Error try/catch blockvoid OnError()

What is Reactive Extensions? Paul Using Rx; 8 November 2014 Raleigh Code Camp Dual-View Comparison of Consumer Interfaces Consumers Pull-Pattern Consumer Push-Pattern Consumer Unsubscribe Dispose()? ResetReset()? Dispose() the IDisposable

Show Accelerometer in Action (Demo) Explanation of Reactive Extensions Explanation of Accelerometer Deep Dive into Some Code Today’s Outline try{ Paul Using Rx; 8 November 2014 Raleigh Code Camp

Show Accelerometer in Action (Demo) Explanation of Reactive Extensions Explanation of Accelerometer Deep Dive into Some Code Today’s Outline try{ Paul Using Rx; 8 November 2014 Raleigh Code Camp

Phidgets USB Accelerometer Phidgets’.Net implementation requires you to register for events Phidgets.Spatial spatial = new Spatial(); spatial.SpatialData += new SpatialDataEventHandler(myMethod); private void myMethod (object sender, SpatialDataEventArgs e) { /*... */ } Brief on Accelerometer and Gyroscope Paul Using Rx; 8 November 2014 Raleigh Code Camp

What “thing” does the Producer produce? Let’s call it the DirectObject class: The Producer pushes a to the Consumers. Brief on Accelerometer and Gyroscope Paul Using Rx; 8 November 2014 Raleigh Code Camp

Phidgets gives me a SpatialDataEventArgs via its event. I transform that into my own class: class AccelerometerFrame_raw { public Vector3D Acceleration; public Vector3D RotationRate; public long TimeStampTicks; } // The first level of Brief on Accelerometer and Gyroscope Paul Using Rx; 8 November 2014 Raleigh Code Camp

I transform a Raw frame into a Processed frame: class AccelerometerFrame_processed { public Vector3D TrueAcceleration; public Vector3D Velocity; public Vector3D Position; public Double SecondsSinceLast; public Vector3D Orientation; } // The second level of Brief on Accelerometer and Gyroscope Paul Using Rx; 8 November 2014 Raleigh Code Camp

Eventually I will have a smoothed frame class: class AccelerometerFrame_smoothed { public Vector3D TrueAcceleration; public Vector3D Velocity; public Vector3D Position; public Double SecondsSinceLast; public Vector3D Orientation; } // The third level of Brief on Accelerometer and Gyroscope Paul Using Rx; 8 November 2014 Raleigh Code Camp

What is the producer class? SpatialDataStreamer_raw : IObservable class SpatialDataStreamer_raw2 // has-a public IObservable DeviceDataStream public class SpatialDataStreamer_processed // has-a public IObservable DeviceDataStream Brief on Accelerometer and Gyroscope Paul Using Rx; 8 November 2014 Raleigh Code Camp

What are the consumer classes? The ViewModel classes for each WPF Window This means they must implement either IObserver or IObserver IObservers must implement OnNext, OnCompleted, and OnError. Brief on Accelerometer and Gyroscope Paul Using Rx; 8 November 2014 Raleigh Code Camp

Show Accelerometer in Action (Demo) Explanation of Reactive Extensions Explanation of Accelerometer Deep Dive into Some Code Today’s Outline try{ Paul Using Rx; 8 November 2014 Raleigh Code Camp

Show Accelerometer in Action (Demo) Explanation of Reactive Extensions Explanation of Accelerometer Deep Dive into Some Code Today’s Outline try{ Paul Using Rx; 8 November 2014 Raleigh Code Camp

Show Accelerometer in Action (Demo) Explanation of Reactive Extensions Explanation of Accelerometer Deep Dive into Some Code Today’s Outline try{ Paul Using Rx; 8 November 2014 Raleigh Code Camp

Switch (AudienceInterest as Pivot) Case Questions: Case WhyIsRxBetterThanEvents Case WhereToUseRx: Case MoreRxExamples: Case WhatLanguagesHaveAnRxImplementation: Case How2HandleNoise: Case MathsOfAccelerometer: Case WhatsNextInDevelopment: Today’s Outline Paul Using Rx; 8 November 2014 Raleigh Code Camp

Catch(FailedPresentationException e) { PaulSingsAcapella( Song["Ill Be Watching You"]); } Finally { Resources On Rx; } Return new WannaTryRxMyself(ref Boss); Today’s Outline } Paul Using Rx; 8 November 2014 Raleigh Code Camp

Luminaries Erik Meijer, Inventor of Bart de Smet, Principal Software Development Engineer at Microsoft Lee Campbell, Introduction to Rx Jim thinqlinq.com Resources On Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp

Getting Started 1. Install Rx from Nuget. Search Nuget for "Rx SDK" to find it Resources On Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp

Getting Started 2. Watch Curing Your Event Processing Blues with Reactive Extensions (Rx) Europe/2012/DEV413 Europe/2012/DEV413 This is a talk given by Bart de Smet Includes Kinect events and Async/Await Resources On Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp

Getting Started 3. Read Introduction to Rx by Lee Campbell Read it like a novel (may help with your insomnia). Is Online at Is also an ebook on Kindle. Note: Don’t use ISubject. See stack overflow Why are Subjects not recommended in.Net Reactive Extensions? Resources On Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp

After you’ve started channel9.msdn.com/tags/Rx Jim Wooley’s website, Jim Wooley’s presentation: Reactive Extensions (Rx) In Action - Code on the Beach 2014 = Resources On Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp

After you’ve started rxwiki.wikidot.com/101samples davesexton.com/blog leecampbell.blogspot.com An Event-driven and Reactive Future - Jonathan Worthington = Resources On Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp

After you’ve started Awaiting for Rx: A Play in Four Acts - Paul Betts, Github (youtube.com or evolve.xamarin.com) Mostly about Rx on Xamarin Betts talks about a project of his that converts UI events to Rx (not just for Xam.) Betts works at github Resources On Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp

Once you’re proficient rxx.codeplex.com Extensions for Reactive Extensions Includes ObservableWeb stuff ObservableNetworkChange Catch, Retry, and OnErrorResumeNext Resources On Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp

If you really like Category Theory The first paper where Erik Meijer announces his discovery that IEnumerable has a Dual: csl.stanford.edu/~christos/pldi2010.fit/meij er.duality.pdf csl.stanford.edu/~christos/pldi2010.fit/meij er.duality.pdf Expert to Expert: Beckman & Meijer - Inside Rx (youtube or channel9) Heavy Math Here Resources On Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp

Catch(FailedPresentationException e) { PaulSingsAcapella( Song["Ill Be Watching You"]); } Finally { Resources On Rx; } Return new WannaTryRxMyself(ref Boss); Today’s Outline } Paul Using Rx; 8 November 2014 Raleigh Code Camp

Catch(FailedPresentationException e) { PaulSingsAcapella( Song["Ill Be Watching You"]); } Finally { Resources On Rx; } Return new WannaTryRxMyself(ref Boss); Today’s Outline } Paul Using Rx; 8 November 2014 Raleigh Code Camp

StackOverflow: philologon Return new WannaTryRxMyself(ref Boss); Paul Using Rx; 8 November 2014 Raleigh Code Camp

CLR Events are not 1 st class Objects. Rx IObservables are. CLR Events are not 1 st class Objects. Rx IObservables are. This means you can pass IObservables around from one class or method to another. (Not so Events) This means you can pass IObservables around from one class or method to another. (Not so Events) Because it’s LINQ, you can consume multiple producers, and merge them to make a new producer. Because it’s LINQ, you can consume multiple producers, and merge them to make a new producer. Because it’s LINQ, you can use Lambas. (Not so Events) Because it’s LINQ, you can use Lambas. (Not so Events) Why Rx is Better than Events Paul Using Rx; 8 November 2014 Raleigh Code Camp

It plays nice with Async/Await It plays nice with Task Helps in isolating state I wrote a concurrent-safe application without even realizing it I wrote a concurrent-safe application without even realizing it Why Rx is Better than Events Paul Using Rx; 8 November 2014 Raleigh Code Camp

_WhyRx.html#WhyRx _WhyRx.html#WhyRx Infrastructure events like from file watcher, system and WMI events Infrastructure events like from file watcher, system and WMI events Sensors or other Devices UI events like mouse move, button click Domain events like property changed, collection updated, "Order Filled", etc. Domain events like property changed, collection updated, "Order Filled", etc. Where to Use Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp

From Jim Wooley, Code on the Beach 2014: var sensorValueLow = from s in Sensor where s.SensorValue < 3 select s.SensorValue; var activeLowValSens = sensorValueLow.Subscribe(someVM); More Rx Examples Paul Using Rx; 8 November 2014 Raleigh Code Camp

From Jim Wooley, Code on the Beach 2014: var diceRoll = from detected in rolldetected.Throttle(400ms) from die in ViewModel.dice.ToObservable().Where (die => !die.Frozen).ObserveOnDispatcher().Do(die =>die.DotCount = null) from result in Randomizer.RollAsync().ToObservable() select new {die, rollDots = result}; More Rx Examples Paul Using Rx; 8 November 2014 Raleigh Code Camp

From Paul Batts, Xamarin Evolve 2014: theWindow.Events().Resize.Merge(theWindow.Events().Move).Throttle(TimeSpan.FromSeconds(5), RxApp.MainThreadScheduler).Subscribe(_ => SavePlacement()); More Rx Examples Paul Using Rx; 8 November 2014 Raleigh Code Camp

From Bart de Smet, Curing … Blues, 2012: Var skeletonFrames = Observable. FromEventPattern< SkeletonFrameReadyEventArgs> ( h => kinect.SkeletonFrameReady += h, h => kinect.SkeletonFrameReady -= h ); More Rx Examples Paul Using Rx; 8 November 2014 Raleigh Code Camp

From Bart de Smet, Curing … Blues, 2012 (part2) : From Bart de Smet, Curing … Blues, 2012 (part2) : var left = from joint in joints let pos = joint[JointType.HandLeft].Position select pos; More Rx Examples Paul Using Rx; 8 November 2014 Raleigh Code Camp

From Bart de Smet, Curing … Blues, 2012 (part2) : From Bart de Smet, Curing … Blues, 2012 (part2) : var rel = (from pos in left where Math.Abs(pos.X) > 0.2 select pos.X < 0 ? "left" : "right“).DistinctUntilChanged(); More Rx Examples Paul Using Rx; 8 November 2014 Raleigh Code Camp

.Net JVM (Java and Scala) JavaScript C++ PHP What Languages Have Rx Paul Using Rx; 8 November 2014 Raleigh Code Camp Perl Haskell Swift Python Ruby (eventually)