• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Real-world applications of the Reactive Extensions
 

Real-world applications of the Reactive Extensions

on

  • 634 views

Some concrete exemples of using the Reactive Extensions (Rx) for app development

Some concrete exemples of using the Reactive Extensions (Rx) for app development

Statistics

Views

Total Views
634
Views on SlideShare
634
Embed Views
0

Actions

Likes
0
Downloads
14
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Real-world applications of the Reactive Extensions Real-world applications of the Reactive Extensions Presentation Transcript

    • Real-world applications of Reactive Extensions for .NET (Rx) Jonas Chapuis, Ph.D., Nexthink S.A.
    • About me jonas.chapuis@nexthink.com www.nexthink.com/careers
    • “Functional programming allows developers to describe what they want to do, rather than forcing them to describe how they want to do it.” Anders Hejlsberg, C# creator
    • Exercise readable compact safe JAY JANE MARRY HARRY Versus:
    • IEnumerable & IEnumerator
    • Oh my… TimeoutException!
    • Ok, how about this: nice
    • IObservable & IObserver
    • Yin & Yang Pull collections Push collections MoveNext() • • • • • In memory collections Database queries Generated sequences Message queues … Rx • • • • • OnNext() Event streams Asynchronous computations Asynchronous queries Asynchronous enumerations …
    • Where does Rx fit? Rx shines for – Declarative syntax & compositionality – Easy time handling (timeout, throttling, etc.) – Error handling – Cancellation – Testing
    • Example: search box • Demo
    • Search pipeline react reactive input search SelectMany search
    • Input pipeline r input Throttle 200ms Where length > 2 DistinctUntilChanged re rea reac reaci reac reactive
    • Race condition react reactive input search search SelectMany
    • TakeUntil react reactive input search TakeUntil(input) search TakeUntil(input) SelectMany
    • Timeout react input search Timeout SelectMany
    • Search example Rx network Property changed events react reactive ... Timer throttle distinct search DictService Task<T> takeuntil selectmany timeout OnNext Observer Timer OnError OnError & OnComplete are terminating, i.e. trigger disposal of the network
    • Example: stock quotes stream • Demo
    • Buffer(5) MSFT 27.56 MSFT 26.4 MSFT 28.1 MSFT {27.56, 26.4, 28.1, 30.2, 25.6} MSFT 30.2 MSFT 25.6 MSFT 29.2 MSFT 32.1
    • Buffer(5,1) MSFT 27.56 MSFT 26.4 MSFT 28.1 MSFT 30.2 MSFT 25.6 MSFT 29.2 MSFT 32.1
    • Example: buffer in time • Demo
    • Interoperability with the TPL • ToObservable() • ToTask()
    • Example: asynchronous spellchecker Demo
    • Rx on other platforms • RxJs – Autocomplete, drag&drop, animation, etc. • RxJava – Used for server-side concurrency (heavy requests instead of multiple light requests) – “functional reactive is superior to futures and callbacks” – using IObservable<T> allows choosing asynchronous or synchronous execution & I/O at runtime • RxRb • RxPy
    • Links • • • • http://www.introtorx.com/ http://blogs.msdn.com/b/rxteam/ Beginner's Guide to the Reactive Extensions http://www.reactivemanifesto.org/
    • “GitHub for Windows uses the Reactive Extensions for almost everything it does, including network requests, UI events, managing child processes […] while still having 100% deterministic, reliable unit tests. The desktop developers at GitHub loved Rx so much, that the Mac team created their own version of Rx and ReactiveUI, called ReactiveCocoa, and are now using it on the Mac to obtain similar benefits.” Paul Betts, GitHub