Before jumping into rx-js operators we have to understand two of the most fundamental concepts which are observable and pipe in rx-js

Now what is an Observable

Usually, an observable is a collection of values that may be updated over time. This means that this collection can be observed by an observer — a collection of callbacks — which will be invoked whenever the data is changed.

To simplify this idea, you can think of it as a very powerful “Event Bus.” You can register to events, deregister from events, and trigger events, quite the same as you would on a regular Event Bus. However, at any step in these operations, you can define an operator function in order to combine, filter, and create new events at any time. This is actually the operation of looking at a stream of data (or better: observing) and performing actions to alter that stream to the application’s needs.

Now lets see some super basic codes around Observable to get its basic nature

An observable is Lazy, Observables will only execute upon subscribe. And if you don’t subscribe it will not start. As long as the observer didn’t subscribe it, it doesn’t emit any value. So I used the subscribe() function to subscribe to this Observable

Image for post

#programming #javascript #typescript #angular #rxjs

Angular RxJs Operators: DebounceTime, RetryWhen and SwitchMap
1.85 GEEK