Presentation is loading. Please wait.

Presentation is loading. Please wait.

Slides license: Creative Commons Attribution Non-Commercial Share Alike See

Similar presentations


Presentation on theme: "Slides license: Creative Commons Attribution Non-Commercial Share Alike See"— Presentation transcript:

1 Slides license: Creative Commons Attribution Non-Commercial Share Alike See http://creativecommons.org/licenses/by-nc-sa/3.0/legalcodehttp://creativecommons.org/licenses/by-nc-sa/3.0/legalcode

2 Rx is a library for composing asynchronous and event-based programs using observable collections. Queries? LINQ? Too hard today…

3 You could get stuck C# 4.0 covariance

4 You could get stuck C# 4.0 covariance (Waiting to move next) moving on

5 Source: http://smartcanucks.cs

6 http://en.wikipedia.org/wiki/Dual_(category_theory) Reversing arrows… Input becomes output and vice versa Making a U-turn in synchrony

7 C# didn’t borrow Java checked exceptions

8 IDisposable ( & ) IEnumerator GetEnumerator( void ); We really got an enumerator and a disposable

9 void IEnumerator IEnumerableDual IEnumerable ) GetEnumerator( Set Will only dualize the synchrony aspect

10 This is an output too

11 Discrete domain with true and false

12 If you got true, you really got a T T

13 If you got false, you really got void void

14 (T | void | Exception) MoveNext( void But C# doesn’t have discriminated unions… Let’s splat this into three methods instead! But C# doesn’t have discriminated unions… Let’s splat this into three methods instead! Got IEnumeratorDual IEnumerator IEnumeratorDual>); IEnumerator x);

15

16 Source: http://amazon.com

17 Used to detach the observer… Do you really know C# 4.0?

18 (*) Visit http://en.wikipedia.org/wiki/Color_of_the_bikeshed

19 You could get flooded C# 4.0 contravariance

20 Environment MoveNext Got next? Application OnNext Have next! IEnumerable IEnumerator IObservable IObserver Interactive Reactive

21

22 OnCompleted OnNext OnError new int[0] new[] { 42 } Throwing iterator Iterator that got stuck Notion of time

23 OnNext(0) OnNext(1) OnNext(2) yield 0 yield 1 yield 2

24 Hypothetical anonymous iterator syntax in C# Synchronous Asynchronous A variant with time notion exists (GenerateWithTime)

25 C# doesn’t have anonymous interface implementation, so we provide various extension methods that take lambdas. C# 4.0 named parameter syntax

26 F10F10

27 F10F10

28 F5F5

29 Breakpoint got hit

30

31 Lack of composition Resource maintenance?

32 Can define operators Resource maintenance!

33 Lack of composition Exceptions?Exceptions? Synchronous completion? Cancel?Cancel? State?State?

34

35

36

37

38

39

40

41

42 React TextChanged Asynchronous request Reaction Reactive Reactor Data binding on UI thread

43 input.SelectMany(term => lookup(term))

44

45 input Service call 1 Service call 2 UI data binding |R|Re|Rea|Reac|React| Reacti| Reactiv| Reactive| Reactive Reaction Reactive Reactor Source: http://scrapetv.com

46 input Service call 1 Service call 2 UI data binding |R|Re|Rea|Reac|React| Reacti| Reactiv| Reactive| Reactive Take Until

47 // Alternative approach for composition using: // IObservable Switch (IObservable > sources) var res = (from term in input select lookup(term)).Switch(); Very local fix Hops from source to source

48

49

50

51

52 IEnumerable E.g. LINQ to Objects IObservable E.g. LINQ to Events IQueryable E.g. LINQ to SQL Fixed (MSIL) Translatable (Expression trees) ToQueryable ToObservable ToEnumerable AsQueryable AsEnumerable AsQbservable AsObservable Pull (interactive) Push (reactive) Concurrency (IScheduler) LINQ to *.* What? Where? How? Worker pools Message loops Threads Distributed Duality Homo-iconic IQbservable E.g. LINQ to PowerShell ToQbservable

53 Rx is a library for composing asynchronous and event-based programs using observable collections. Queries! LINQ! Way simpler with Rx

54


Download ppt "Slides license: Creative Commons Attribution Non-Commercial Share Alike See"

Similar presentations


Ads by Google