2017-08-09 1 views
0

私のIonic 2プロジェクトでは、プロバイダークラスで1分ごとにサーバーからデータをダウンロードしています。新しいデータが来るたびに、ページクラスのグラフを更新する必要があります。 これは、コードが単純化されたバージョンでどのように見えるかです:[?RxJs観測ネストされたサブスクリプション]最初に完了したときに次のオブザーバーに電話するには?

let startTime = new Date(Math.ceil(new Date().getTime()/60000) * 60000); 
    this.Source = Rx.Observable.timer(startTime, 60000).timeInterval().pluck('interval'); 

    this.Subscription = this.Source 
    .subscribe(data => { 

      this.http.post(this.ConnectionString) 
      .map(res => res.json()) 
      .subscribe(data => { 
      //code 
      }); 
    }); 
+0

の可能性の重複を使用して、このように試すことができます(https://stackoverflow.com/question/42888604/rxjs-observables-nested-subscriptions) – cartant

答えて

0

あなたはObservable.interval

//Time in milleseconds 
    Observable.interval(15000).flatMap(x => this.http.post(this.ConnectionString)) 
     .map(res => res.json()) 
     .subscribe(data => { 
     //code 
     }); 
+0

私は、これが完了したときに別の観測可能なものを通知する方法を尋ねています – ChristoK

+0

subscribe中に他の観測可能なものを呼び出すか、flatMap – Sreemat

+0

を使用します。これは私の質問のポイントです – ChristoK

関連する問題