The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

What RxJS operators are

What RxJS operators are

5:38
We have covered the basics of what is Observable.create, and other creation functions. Now lets finally dive into operators, which are the focus of this course. We will see how operators are simple pure functions attached to the Observable type.
Watch this lesson now
Avatar
egghead.io

We have covered the basics of what is Observable.create, and other creation functions. Now lets finally dive into operators, which are the focus of this course. We will see how operators are simple pure functions attached to the Observable type.

Avatar
Jimish

I am confused when to use map and subscribe, seems like I can write the code written in subscribe in map as well, please help !!

Avatar
Andre

Jimish, have you watched the previous course on creating Observables? https://egghead.io/courses/rxjs-beyond-the-basics-creating-observables-from-scratch
A subscribe will invoke the execution of the Observable, but a map will not invoke the execution, it simply returns a new Observable. That returned Observable needs to be subscribed in order to execute. In general, we should never put side effects inside a map operator. Side effects must happen only in a subscribe. The map operator is meant simply for basic data transformation.

In reply to Jimish
Avatar
Anton Telesh

Why didn't you return the unsubscribe function from the new observable you just created? Is it for simplicity of the lesson?

Avatar
Andre

Yes Anton, for simplicity. It's important not to introduce too many concepts too quickly. This lesson focus on just one goal: how operators make chains of Observables that subscribe to each other.

In reply to Anton Telesh
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?