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

WTF are Observables?

By Eran Schoellhorn

WTF are Observables?

With observables and functional reactive programming popping up more and more from the ethos of web development, "WTF are Observables?" is a much needed introduction to observables, RxJS, and FRP to intermediate JavaScript developers. Combining fun examples and anecdotes, visitors leave this talk with everything they need to know to get started with RxJS and are invigorated to learn more and begin applying functional principles to their Javascript practice.

  • 2,047