Reactive Programming

Some Definitions

  • Reactive Programming
    • Reactive programming is programming with asynchronous data streams - AndrĂ© Staltz
  • Streams
    • Information that is ordered in time

      • Emit values, errors, or completion

      • Immutable

Why should you care?

A: You're already using it!

A: It's how the world works

A: It's the new hotness

A: It's more robust

Time & Safety

How do I use it?!

How do I use it?!

  • Microsoft Reactive Extensions (RxJS)
  • Bacon.js
  • Cycle.js
  • Elm
  • ...And many more!
const Rx = require('rxjs/Rx')

const source = Rx.Observable.interval(1000);

const subscription1 = source.subscribe(
  x => console.log('Observer 2: onNext: ' + x),
  e => console.log('Observer 1: onError: ' + e.message),
  () => console.log('Observer 1: onCompleted'));

const subscription2 = source.subscribe(
  x => console.log('Observer 2: onNext: ' + x),
  e => console.log('Observer 2: onError: ' + e.message),
  () => console.log('Observer 2: onCompleted'));

setTimeout(() => {
  subscription2.unsubscribe();
  subscription1.unsubscribe();
}, 5000);

Learn More:

Made with Slides.com