Operator type
Creator Operator
Transforming Operator
Filtering Operator
Combining Operator
Conditional & Boolean Operator
Mathematical & Aggregate Operator
Error Handling Operator
Utility/Tool Operator
Multicasting Operator
-source Observable => emit Observable (higher-order function) -no mute current Observable but do something on value inside
an Observable context => Functor -Even inside an Observable of Observable => Monad
Operator Optimization
- Same data reference through Observables => not like plain vanilla Array prototype method - New set of data each Observer
Subscription
Static|Observable methods / Observable factory
VS
Instance methods / Observable instance methods
Static => Initiate Producer (Creator & Combination Operator)
Instance => Pipeline Operation
Static directly define inside Rx.Observable Object - Instance method define inside Observable prototype chain.
bindCallback
bindNodeCallback
combineLatest
concat
create
defer
empty
forkJoin
from
fromEvent
fromEventPattern
fromPromise
interval
merge
never
of
range
throw
timer
webSocket
zip
=> 21 static Observable Methods
Core/Common/Main Operator
Map Operator
Rx.Observable.fromEvent(document, 'click')
.map(ev => ev.clientX)
It passes each source value through a transformation function to get corresponding output values
Applies a given project function to each value emitted by the source Observable, and emits the resulting values as an Observable
Filter Operator
Rx.Observable.timer(0, 1000)
.filter(x => x % 2 === 0)
It only emits a value from the source if it passes a criterion function
Filter items emitted by the source Observable by only emitting those that satisfy a specified predicate
Reduce Operator
Rx.Observable.timer(0, 1000)
.take(6)
.reduce((acc, cur) => acc += cur, 0)
Combines together all values emitted on the source, using an accumulator function that knows how to join a new source value
into the accumulation from the past
Applies an accumulator function over the source Observable, and returns the accumulated result when the source completes,
given an optional seed value
Scan Operators
It's like reduce, but emits the current accumulation whenever the source emits a value
Applies an accumulator function over the source Observable, and returns each intermediate result, with an optional seed value
Exercice
Count the number of 'T' character from a text
Get the most used character
- Make this exercice is easy because one big part of the exercice is already done
=> formulate "WHAT" we want in a soft programming
Nevertheless, we have to do that shift by yourself so try your hand is essential to be used to adopt this approach
Count the number of 'T' => //jsfiddle.net/Echyzen/7jmh0nc3/
Get the most used character => https://jsfiddle.net/qejzte93/
new one => https://jsfiddle.net/Echyzen/y03zoLvj/