RxJS is a library for composing asynchronous and event-based programs by using observable sequences. It provides one core type, the Observable, satellite types (Observer, Schedulers, Subjects) and operators inspired by Array#extras (map
,filter
,reduce
,every
, etc) to allow handling asynchronous events as collections.
Observable represents the idea of an invokable collection of future values or events
โSubscription represents the execution of an Observable, is primarly useful cancelling the execution.
Observer is a collection of callbacks that knows how to listen to values delivered by the Observable
next
, error
, completed
which specifies way Observable Execution can deliver in other words those methods tells Observable what to do:next
defines what to do with the value emitted, it is the only on requirederror
specifies how to behave in error casescompleted
defines behaviour when there are no more values to emit.map
, filter
, tap
, first
, debounceTime
, skipUntil
... Operators allow complex asynchronous code to be easily composed in a declarative manner. It is like a function that may change the river or things that are next to it.pipe
Operator has the super power of chaining operators. And since each operator takes in an Observable and returns new one as the result we still have an Observable, no matter how many operators we've used!.subscribe()
to it as well as call methods .next()
, .error()
and .complete()
on it.โSchedulers are centralized dispatchers to control concurrency, allowing us to coordinate when computation happens on e.g. setTimeout or requestAnimationFrame or others.