1分毎に約束を返す方法はありますか? 私はこのような何かをしようとしていたが、それは最初に一度だけの約束を返します。1分ごとに約束を返しますか?
startWork() {
this.dataService.startPing(details).then((result) => {
this.timeSlotsRefresh();
}, (err) => {
console.log(err);
});
}
、その後:
startPing() {
let startingTime = new Date();
return new Promise((resolve, reject) => {
let source = Rx.Observable.timer(startingTime, 60000).timeInterval().pluck('interval');
this.Subscription = source
.subscribe(data => {
this.http.post('http://localhost:63203/api/Ping', JSON.stringify(this.offlinePings[i]))
.map(res => res.json())
.subscribe(data => {
resolve(data);
}, (err) => {
reject(err);
});
});
});
}
それは基本的にこの機能を1分ごとに通知しなければなりませんthis.timeSlotsRefresh();
を呼び出してデータをリフレッシュするには、どうすればいいですか?
:
interval
オペレータとrx
を使用して? –
あなたは私にそれの例を教えてくれますか? – ChristoK
https://stackoverflow.com/questions/35592716/making-polling-request-in-angular-2-using-observable –