Streams principle

FP + RP + OPP DP (Observer + Iterator) = FRP => RxJS

FP

  • Lazy evaluation
  • Functor
  • Monad

OOP

  • Observer
  • Iterator
Everythink is a stream!

Unidirection data flow

RxJS Stream schema

Stream pipeline (side effects postponed after => concern the consumer)

RxJS Component

Abstract the notion of time

Why Observable vs Observer?

Decoupled Business Logic from View (so side-effect) => Separation of concerns

Observable liability

Observer liability

RxJS API & lifecycle

RxJS Observable schema
next*(error|complete)?

Implementation


            // Implementation Example
            [const subscription =] stream$.timerInSeconds()             // Producer
                .interval()                                             // pipeline
                .map(x => x.value)                                      // pipeline
                .filter(x => x % 2 === 0)                               // pipeline
                .take(10)                                               // pipeline
                .subscribe(val => console.log(val))                     // consumer