$30 off During Our Annual Pro Sale. View Details »

RxJS Introduction

RxJS Introduction


July 25, 2016

More Decks by r31gN_

Other Decks in Technology


  1. RxJS introduction

  2. Current state of UIs • Extremely complex • Full of

    async events, client/server communication • UIs are always composed based on a state • State is hard to reason about
  3. Imperative programming

  4. None
  5. User action UI Responds User action ….. Uses imperative programming

    Uses imperative programming UI Responds time (s)
  6. Caveats of IP • Isolates state from time • You

    don’t see the bigger picture • Mutable values
  7. Is there a way … ?

  8. Reactive programming

  9. – Andre Staltz “Reactive programming is programming with asynchronous data

  10. Streams • Sequence of ongoing events ordered in time •

    Cheap, ubiquitous • Allow you to react to new data • Think event busses, typical click events, etc.
  11. But in RP …

  12. None
  13. Observable/Observer • Observables are push-based, observable sequences that can send

    data to anyone who is interested • Observers are entities who register an interest through a subscription to an Observable
  14. Observers • Register via subscribe method • You get back

    a Disposable object (a handler for the subscription) • onNext, onError, onCompleted
  15. Demo time with RxJS

  16. When to use RxJS • Orchestrate event-based computations • Deal

    with async data • Complex UIs with lots of user interaction
  17. Thank you! @r31gN_ https://github.com/r31gN/rxjs-demo-workshop