RxJS – Taming the Async Beast – FRP to the Rescue



RxJS – Taming the Async Beast – FRP to the Rescue

0 0


rxjs-presentation


On Github Jiri-Kremser / rxjs-presentation

RxJS

Taming the Async Beast

Jiří Kremser < jkremser(at)redhat.com >

#hawkular on Freenode

2016-01-27

Applied Duality

Single value Mutiple values Pull/Synchronous/Interactive Object Iterable Push/Asynchronous/Reactive Promise Observable

Applied Duality

Single value Mutiple values Pull/Synchronous/Interactive Object Iterable Push/Asynchronous/Reactive Promise Observable

A-sync?

Asynchronous Programming is Annoying

  • Each framework has its own way of expressing async/event-based programming
    • Node.js has callbacks, .then we have Promises, and then events
    • Each concept covers only part of the story
  • Unification by Observables

Uber Standard?

FRP to the Rescue

  • Functional Reactive Programming
  • Language agnostic model with 3 concepts:
  • Observer, Observable
  • Query operations (filter, map, reduce, etc.)
  • How, Where, When (Schedulers)language in language

What is Observable?

  • represents a push based collection
  • any number of values over any amount of time
  • can be combined w/ other observables
  • memory effective
  • monad

Observable vs Iterable

Iterable Observable pull push T next() onNext(T) throws Exceptions onError(Exception) return; onCompleted()
            (onNext)*(onError|onCompleted)?

Observable vs Promise

  • cancelation
  • Rx.Observable.from(promise)
  • Promise.then() ~ Observable.flatMap()
  • ...

Combinators

  • a type constructor M and two operations, bind and return
  • flatMap - bind function
  • Observable.of() - return / unit function
  • Marble diagrams

Implementations in *.js

RX is everywhere

  • Java
  • .NET
  • Scala, Groovy, Clojure
  • Objective-C
  • Android SDK
  • C++
  • Python
  • Ruby
  • Dart
  • PHP
  • Haskell
  • ...

Stream

Demo

Talk is cheap ;)

Live long and prosper

This presentation

https://goo.gl/vG6J7J