Intro to RxJs

OR: "Introduction to Observables"

OR: "WTF are Observables?"

Eran Schoellhorn

352 Inc.

About me

  • Javascript Developer
  • Wannabe Musician
  • Family Man

Contact

@swellhorn

me@eran.sh

github.com/Swingline0

ASYNCHRONY

aka The First Mindfuck of JavaScript

  
  function doSomething() {
    // Does stuff
    return computedThing;
  }
var mahDatas = doSomething();
// => undefined

Me

ASYNCHRONY

aka The First Mindfuck of JavaScript

  
  function doSomething(callback) {
    // Does stuff
    return callback(computedThing);
  }
var mahDatas = doSomething(val => {
  console.log(val)
});

Everything is async

  • Application Lifecycle
  • AJAX
  • I/O
  • Users

deal with it

  • Callbacks
  • Promises
  • Fibers
  • Async/Await
  • Generator Functions

click

..... click

 .............. click

 .................... click 

click

..... click

 .............. click

 .................... click 

 💥

 💥

 💥

 💥

[click, click, click, click, etc.]

Proposed, native JavaScript Feature

Observables are collections of events

ReactiveX

Language agnostic API definition for implementing Observables.

  • Java
  • JavaScript
  • C#/C#(Unity)
  • Scala
  • Clojure
  • C++
  • Ruby
  • Python
  • Swift
  • and more...

RxJS

  • Collaborative Effort between Google, Microsoft, & Netflix
  • Open Source (Apache v2)
  • Works in browser or NodeJS
  • Safari 7+, IE9+

1. BASICS

2. DEMO

3. ???

Tl;DR: RxJS

  • Handle Async events with declarative API
  • Helps avoid memory leaks with teardowns
  • Easily transform or combine streams
  • Stepping stone to FRP!
  • Streams only become active when subscribed

FAT RED PIG

Le DEMO

RESOURCES

Made with Slides.com