5
如何在retryWhen
中設置延遲?Observable「retryWhen」delay
import 'rxjs/add/operator/retry';
import 'rxjs/add/operator/retrywhen';
...
constructor(http: Http) {
var headers = new Headers();
headers.append('Content-Type', 'text/plain');
http.post('https://mywebsite.azurewebsites.net/account/getip', "", { headers: headers })
.retryWhen(errors => {
return errors.delay(1000); // errors is not a function
})
(event) => {
// handle events
this.ip = event.json();
},
(error) => {
console.error(error);
toastr.error('No connection to server. Please reload the page!')
}
);
}
我得到的錯誤:errors is not a function
。
檢查此鏈接http://www.unknownerror.org/opensource/ReactiveX/RxJava/q/stackoverflow/22066481/rxjava-can-i-use-retry-but-with-delay – rashfmnb
是這是你的確切代碼?如果是這樣,你有語法錯誤(括號不匹配等)。你能格式化代碼嗎? –
這不是我的代碼,我剛剛從這裏找到了解決方案,這就是爲什麼我在這裏分享它的原因 – rashfmnb