Exploring RxJs Operators - filter
In a previous post I gave an introduction to the observable and included some information on piping operators but I feel like each operator deserves its own post even if the post is going to be reasonably small. In this post, I thought we would look over the filter operator given that it will probably be one of the most commonly used operators for many developers. As the name suggests filter filters values from the stream of values that an observable emits, let's start with an example: 1| this.keyboardEvents.pipe( 2| filter(event => event.key === 'Enter'), 3| tap(() => console.log('Enter pressed!') 4| ); Let's talk about each line of code, line 1 is simple enough; the keyboardEvents observable emits a KeyboardEvent . Line 2 is where we will focus most of our attention on, the filter operator, in this case, will filter out any KeyboardEvent objects that do not have 'Enter' as its key. Line 3 just verifies what I have alr