In one Angular Component I'm dealing with three or four Observables. I need to refactor this some way in order to avoid this poorly written code with ugly nested subscribe calls. It's important as you can see that productService should be called before queryParamMap, while call to categoryService isn't crucial.
I tried to refactor this with forkJoin and switchMap but without success.
this.productService.getAll()
      .subscribe(
        (products: any) => {
          this.products = products;
          this.categoryService.getAll()
            .subscribe(categories => this.categories = categories);
          this.route.queryParamMap
            .subscribe(params => {
              this.category = params.get('category');
              if (this.category) {
                this.productService.getProductsByCategory(this.category)
                  .subscribe(fProducts => this.filteredProducts = fProducts);
              } else {
                this.filteredProducts = this.products;
              }
            },
              err => {
                console.log(err);
              }
            );
        });  

