RxJS 6 examples in Angular 6 – Filtering Operators

Some more RxJS 6 examples in Angular 6. Each example follows the new Angular 6 RxJS 6 coding styles so they are tree-shakable and future-proof.

 

filter – How to filter values from a stream

The “filter” operator takes a function which returns true or false. e.g. filter(x => x % 2 === 0).

Try out the example on StackBlitz.

 

take – How to take x number of values before completing

e.g. take(5).

Try out the example on StackBlitz.

 

takeUntil – How to take values from one observable until another observable emits

e.g. takeUntil(timer(5000)).

Try out the example on StackBlitz.

 

first – How to emit the first value or first to pass provided expression

e.g. first(x => x % 2 === 0).

Try out the example on StackBlitz.

 

last – How to emit the last value based on the provided expression

e.g. last(x => x % 2 !== 0).

Try out the example on StackBlitz.

 

Other articles in this series

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.