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

Dealing with streams using RxJs

Dealing with streams using RxJs

Hugo Cordier

June 05, 2015
Tweet

More Decks by Hugo Cordier

Other Decks in Programming

Transcript

  1. Hello! I am Hugo Cordier Developer and CTO at Melusyn

    Melusyn helps film makers to manage and organize their productions. You can find me at : @HugoCrd We are hiring! Drop me a line at [email protected]
  2. The Rx Model A stream is an Observable An Observable

    push down events through Operators
  3. The Rx Model Operators transform a stream They can be

    used to transform, filter and mix events from an Observable
  4. An Observable needs to be subscribed The Rx Model The

    stream will flow once it has been subscribed
  5. In real life Live search Using Google Geocoder and RxJS

    http://codepen.io/HugoCrd/pen/vOxQvM
  6. In real life Realtime statistics Ping a server each x

    seconds and diplay results http://codepen.io/HugoCrd/pen/dPeaLY
  7. In real life with... Node.js Node uses Callbacks. They can

    easily be used as a stream var rename = Rx.Observable.fromNodeCallback(fs.rename); rename('file1.txt', 'file2.txt') .map(...) .subscribe(...)
  8. In real life with... Angular.js Angular $watch is a stream

    of model changes Angular also has an eventbus system : events on a handler are a stream Rx.Observable.$watch(scope, 'name') .map(...) .subscribe(...)
  9. In real life with... Backbone.js Binding to an object is

    listening to it’s changes. This could be used as a stream. Rx.Observable.fromEvent(object, ‘click’) .map(...) .subscribe(...)
  10. In real life with... JS Wokers A worker could post

    messages to into stream Rx.DOM.fromWebWorker('worker.js') .map(...) .subscribe(...)