
Filtering with RxJS
Filtering of observables can be done in different ways. These are the best options for some different use-cases.
The filter operator
In case the only thing you want to do is skip entire emits from the source observable based on a filter. the filter operator gets the job done perfectly.
The map operator
Most of the time filtering is done on the contents of an emitted value. To make this possible we can use the map operator and apply the filtering to the content of every emit of the source observable.
The combine operator
The previous examples all had static filters, as this is not always the case filtering can also be done with a combination of the combine operator and the map operator. This can be done by making an observable for the filter values and combining the source observable and the filter observable.
The advantage of this approach is that by updating either of the source observables (resultset or filter in this case) a new value is emitted with the result of the last emitted values of both.