code reactions - an introduction to reactive extensions

39
Code Reactions – An Introduction to Reactive Extensions Jason Bock Practice Lead

Upload: jasonbock

Post on 17-Jul-2015

132 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Code Reactions - An Introduction to Reactive Extensions

Code Reactions – An Introduction to Reactive Extensions

Jason BockPractice Lead

Page 2: Code Reactions - An Introduction to Reactive Extensions

»http://www.magenic.com

»http://www.jasonbock.net

»https://www.twitter.com/jasonbock

»https://www.github.com/jasonbock

» [email protected]

Personal Info

Page 3: Code Reactions - An Introduction to Reactive Extensions

https://github.com/JasonBock/

CodeReactions

Downloads

Page 4: Code Reactions - An Introduction to Reactive Extensions

»Why Rx?

»Using Rx

Overview

Remember…

https://github.com/JasonBock/

CodeReactions

Page 5: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

http://frmilovan.files.wordpress.com/2010/05/ford-assembly-line.jpg

Page 6: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

http://icons.iconarchive.com/icons/3xhumed/tools-hardware-pack-4/256/CPU-Z-icon.png

Page 7: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

MainWindow.xaml<Button

Click="OnStartListeningClick" />

MainWindow.xaml.csprivate void OnStartListeningClick(

object sender, RoutedEventArgs e){

// ...}

Page 8: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

http://www.lolroflmao.com/wp-content/uploads/2012/05/wrong-wrong-wrong.jpg

Page 9: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

http://www.redorbit.com/media/uploads/2013/03/ChemicalReactions_031513-617x416.jpg

http://icyroadsafety.com/parts/blackice1.jpg

http://www.venelogia.com/uploads/mandrake/2012-movie.jpg

Page 10: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

http://icons.iconarchive.com/icons/3xhumed/tools-hardware-pack-4/256/CPU-Z-icon.png

Page 11: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

http://techblog.netflix.com/2013/01/reactive-programming-at-netflix.html

http://savas.me/2014/04/reactive-computing-at-the-heart-of-cortana/

http://reactconf.com/

Page 12: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

Page 13: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

http://2.bp.blogspot.com/-6m8BQlS7-

g8/UArVdKi8yJI/AAAAAAAADFs/tcUDGbkm9Hg/s1600/ChemicalExplosion.jpg

Page 14: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

http://wondrouspics.com/wp-content/uploads/2012/04/bomb-explosion-nuclear-explosions-wallpaper-

540x337.jpg

Page 15: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

StocksDB

What is the current stockprice for MSFT?

37.96 (3/3/2014, 8:32:00 AM Central)

Page 16: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

StocksDB

What is the current stockprice for MSFT?

Page 17: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

StocksDB

37.97

37.98

Tell me when the stockprice changes for MSFT

Page 18: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

Comment feeds

Sensor data

Key logging

Navigation events

File watching

UI events

Game play

Page 19: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

http://www.reactivemanifesto.org/images/full-reactive.png

Page 20: Code Reactions - An Introduction to Reactive Extensions

Why Rx?

http://rehansaeed.co.uk/reactive-extensions-part1-replacing-events/

Page 21: Code Reactions - An Introduction to Reactive Extensions

Using Rx

.NET

Java

C++

Ruby

JavaScript

Python

https://github.com/Reactive-Extensions

Page 22: Code Reactions - An Introduction to Reactive Extensions

Using Rx

Page 23: Code Reactions - An Introduction to Reactive Extensions

Using Rx

http://blog.sudobits.com/wp-content/uploads/2011/08/keylogging-on-ubuntu.jpg

Page 24: Code Reactions - An Introduction to Reactive Extensions

» In .NET 4.0

› IObserver<T>− OnCompleted()

− OnError(Exception e)

− OnNext(T value)

› IObservable<T>− Subscribe(IObservable<T> observer)

Using Rx

Page 25: Code Reactions - An Introduction to Reactive Extensions

Demo: Observe Key PressesCode Reactions –An Introduction to Reactive Extensions

Page 26: Code Reactions - An Introduction to Reactive Extensions

Using Rx

public class MyObservable: IObservable<char>

Observable.FromEventPattern(...)

Page 27: Code Reactions - An Introduction to Reactive Extensions

Demo: Creating ObservablesCode Reactions –An Introduction to Reactive Extensions

Page 28: Code Reactions - An Introduction to Reactive Extensions

Using Rx

the quick brown fox jumped over the lazy dog

ECBFEDEEADG.Where(…) .Take(…) 6.4 seconds

Page 29: Code Reactions - An Introduction to Reactive Extensions

Demo: Modifying ObservablesCode Reactions –An Introduction to Reactive Extensions

Page 30: Code Reactions - An Introduction to Reactive Extensions

Using Rx

the quick brown fox jumped over the lazy dog

OnError()

Retry()

Page 31: Code Reactions - An Introduction to Reactive Extensions

Demo: Exceptions and ObservablesCode Reactions –An Introduction to Reactive Extensions

Page 32: Code Reactions - An Introduction to Reactive Extensions

Using Rx

http://www.teetshirts.com/images/uploads/volume-to-11.jpg

Page 33: Code Reactions - An Introduction to Reactive Extensions

Using Rx

REST API KeyloggerWeb API

Sig

nalR

Page 34: Code Reactions - An Introduction to Reactive Extensions

Demo: Keylogger PipelineCode Reactions –An Introduction to Reactive Extensions

Page 35: Code Reactions - An Introduction to Reactive Extensions

Using Rx

http://social.eli.ubc.ca/files/2011/08/fail.jpg

Page 36: Code Reactions - An Introduction to Reactive Extensions

Using Rx

http://nimitdholakia.files.wordpress.com/2011/01/time.jpg

Page 37: Code Reactions - An Introduction to Reactive Extensions

Demo: Unit Testing and RxCode Reactions –An Introduction to Reactive Extensions

Page 38: Code Reactions - An Introduction to Reactive Extensions

Using Rx

http://www.dotnetfoundation.org/

Page 39: Code Reactions - An Introduction to Reactive Extensions

Code Reactions – An Introduction to Reactive Extensions

Jason BockPractice Lead

Remember… https://github.com/JasonBock/CodeReactions http://www.slideshare.net/jasonbock/code-reactions-an-

introduction-to-reactive-extensions References in the notes on this slide