Understand RxJS Operators

InstructorAndré Staltz

Share this video with your friends

Send Tweet

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.

🚨 Since we are importing interval from RxJS, we don't need to preface our Observables with Rx.Observable. Observable.create is deprecated, use new Observable instead. You can no longer .{operator}, you need to .pipe({operator}) instead.

Jimish
~ 8 years ago

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 !!

André Staltzinstructor
~ 8 years ago

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.

Anton Telesh
~ 8 years ago

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

André Staltzinstructor
~ 8 years ago

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.

Damian
~ 6 years ago

I love that you have so many quality courses on RxJS, but are there plans to update them to use RxJS 6?