Observables

Reactive Programming

Reactive Programming?

 

  • Reactive programming is programming with asynchronous data streams.

  • So... it's like an Event Bus? ... yes but with steroids.

  • EVERYTHING can be a stream.

  • Variables, user inputs, properties, caches, data structures, etc.

  • You can listen to those streams and react accordingly.

Design Patterns

 

Iterator

Observer

Observer++

  • Subscribe (Observable.subscribe())
  • Unsubscribe (Subscription.unsubscribe())
  • Notify (Observer.next())
  • Error (Observer.error())
  • Complete (Observer.complete())

Observables/Streams

  • Collections of data that arrives in future time (async).
  • The Observable object represents the object that sends notifications (the provider); the Observer object represents the class that receives them (the observer).

EVERYTHING can be a stream.

https://codepen.io/joshblack/pen/zGZZjX

https://www.learnrxjs.io/operators/

https://rxviz.com/

http://rxmarbles.com/

Observables

By Cesar Guerrero Rincon