Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tyrannosaurus Rx

James Hughes
September 03, 2014

Tyrannosaurus Rx

Basic overview of Rx (Reactive Extensions)

James Hughes

September 03, 2014
Tweet

More Decks by James Hughes

Other Decks in Programming

Transcript

  1. var list = [1,2,3,4,5,6,7]; ! for(var i = 0; i

    < list.length; i++) { console.log(list[i]) }
  2. CREATING OBSERVABLES class _ extends Subscriber<String> { void onCompleted() {}

    void onError(Throwable t) {} void onNext(String s){} }
  3. TRANSFORMING OBSERVABLES Observable ints = Observable .interval(1, SECONDS); ! ints.map((i)

    -> i + 1) .map((i) -> i + “ seconds”) .subscribe(out::println)
  4. COMBINING OBSERVABLES Observable goodies = Observable.from( new String[]{ "Batman", "Robin",

    "Alfred", “Batgirl"}); ! goodies.zipWith(baddies, (g,b) -> g + " punches " + b)
  5. COMBINING OBSERVABLES Batman punches The Joker Robin punches The Riddler

    Alfred punches Penguin Batgirl punches Catwoman