Filter Events with RxJS Operators take, first, and skip

Share this video with your friends

Send Tweet

There are more operators in the filtering category besides filter(). This lesson will teach how take(), first(), and skip() are simply operators to ignore or pass a certain amount of events from the source Observable.

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

Andrew Greenberg
Andrew Greenberg
~ 9 years ago

foo.first() and foo.take(1), are not equivalent, at least on an edge case.

If foo is an empty observable, foo.first() throws an EmptyError, while foo.skip(1) returns an observable equivalent to Observable.empty(). The former requires that you either provide a defaultIfEmpty or a .catch.

André Staltz
André Staltz(instructor)
~ 8 years ago

Correct, Andrew. Thanks for pointing it out!