2017-05-16 14 views
0

自体を繰り返す:getStyles() - のconfigs内のすべてのconfig.idについて> getPrices()観察可能なチェーン

は、_APIService.getStyleByIDは() "と呼ばれるスタイルオブジェクトを返します。解像度は、私が経験していますガレージ 『

getStyles(configs: any) { 
     configs.forEach(config => { 
      this._APIService.getStyleByID(config.id).subscribe(
       res => { 
        res.config = config; 
        this.getLease(res); 
       } 
      ); 
    }); 

    } 

    getLease(style: any): void { 
     this._priceService.getPrice().subscribe(
     price => { 
      style.price = price; 
      this.garage.push(style); 
      console.log(this.garage); 
     }); 
    } 


} 

問題は上行われてループが存在することである」、このスタイルオブジェクトは、価格がそれに付加され、その後、という配列をプッシュされgetLease()に渡されます』 _APIService.getStyleByID。私のサービスメソッドを設定ごとに一度だけ呼び出すように修正するにはどうすればよいですか? (それが2〜3倍以上のconfigsのアレイの上に再帰する。

答えて

0

subscribetake(1)を追加することで、これは固定私の問題。