How can I keep all the logic in combineLatest from this.route.paramMap but add one more condition?

I am changing this.subscription1 = this.route.paramMap to this.subscription2 = combineLatest([this.route.params,this.route.queryParams] and want to keep all the logic as this.subscription1 = this.route.paramMap except want to add one more condition in this.subscription2 = combineLatest([this.route.params,this.route.queryParams] if queryParams has mode “dealNumber” then I want to return of(this.myService.loadDealByNumber(dealNumber)); else I want to return of(this.myService.loadDealById(dealId));

this.subscription1 = this.route.paramMap
      .pipe(      
        map(params => params.get('deal_id')),        
        mergeMap(dealId => {         
          if (this.dealForm) {
            this.dealForm.form.markAsPristine();
          }
          if (dealId !== 'new') {             
              //Here I want to check if queryParams has mode "dealNumber" then I want to return of(this.myService.loadDealByNumber(dealNumber)); else I want to return of(this.myService.loadDealById(dealId));
              
          } else {
            return this.abcDealer$.pipe(
              tap((dealer: DealerModel) => {
                this.myService.newDeal(dealer);
              })
            );
          }
        })
      )
      .subscribe();
      
      
     this.subscription2 = combineLatest([
      this.route.params,
      this.route.queryParams
    ]).pipe(
      tap(res => console.log('combineLatest - params - queryParams', res)),
      map(([params, queryParams]) => ({
        params,
        queryParams }))
      )
      .subscribe();

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.