title: Angular rxjs filter observable
body: <p>I'm trying to filter an observable of products with an array of filters but i really don't know how..</p>
  
  <p>Let me explain, I would like to set the result of my filtering to filteredProducts.
  For filtering i have to check, for each filter, if the product's filter array contains the name of the filter and if the products values array's contains filter id.</p>
  
  <p>For the moment, the filter works but only with the last selected filter and i'd like to filter products list with all filters in my selectedFilters array. I can have one or multiple filters.</p>
  
  <p><a href="https://stackblitz.com/edit/angular-ivy-bhkjre?file=src%2Fapp%2Fapp.component.ts" rel="nofollow noreferrer">StackBlitz</a></p>
  
  <pre><code>export class ProductsFilterComponent extends BaseComponent implements OnInit {
      @Select(FiltersState.getAllFilters) filters$: Observable&lt;any&gt;;
      @Input() products$: Observable&lt;Product[]&gt;;
      filteredProducts$: Observable&lt;Product[]&gt;;
      public selectedFilters = [];
  
      constructor(
          private store: Store) { super(); }
  
      ngOnInit() {
          this.store.dispatch(new GetAllFilters());
      }
  
      private filterProducts() {
          this.filteredProducts$ = this.products$.pipe(
              map(
                  productsArr =&gt; productsArr.filter(
                      p =&gt;
                          p.filters.some(f =&gt; this.selectedFilters.some(([selectedF]) =&gt; selectedF === f.name.toLowerCase()) // Filter name
                              &amp;&amp; f.values.some(value =&gt; this.selectedFilters.some(([, filterId]) =&gt; filterId === value)) // Filter id
                          )
                  )
              )
          );
          this.filteredProducts$.subscribe(res =&gt; console.log('filtered:', res));
      }
  }
  </code></pre>
  
  <p>Here's the structure of a product object
  <a href="https://i.stack.imgur.com/o7LPb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o7LPb.png" alt="Here&#39;s the structure of a product object"></a></p>
  
  <p>Here's the structure of selectedFilters
  <a href="https://i.stack.imgur.com/BfoqL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BfoqL.png" alt="enter image description here"></a></p>
  
  <p>A big thank you in advance :-).</p>