我正在使用 Google JS 闭包库 https://developers.google.com/closure/library/
我有以下代码:
if (endDate >= wap.com.ifx.util.IfxComponentUtil.yyyymmdd(currentDate) && goog.object.isEmpty(token)) {
if (goog.isDefAndNotNull(this.reloadGridPromise_)) {
this.reloadGridPromise_.cancel('[INFO]Canceling');
}
this.reloadGridPromise_ = new wap.core.net.partialupdate.partialUpdate('getFilteredHistoryList?' + get_params(
vars), this.updateGridFlag);
var self = this;
this.reloadGridPromise_.then(function(response) {
//something
}
该代码块每 5 秒重复一次。我可以在 Google CHrome 开发者工具中看到以下请求
当我调试 js
代码时,我看到此语句 this.reloadGridPromise_.cancel('[INFO]Canceling');
正在执行。但是,我在 Chrome 开发者工具中看不到请求有任何变化。
Google Clousre promise https://google.github.io/closure-library/api/goog.Promise.html
应该是这样吗?
最佳答案
您无法取消 Promise。如果您不想取消请求,则必须使用 Obesrvers 而不是 Promise。所以也许看看:http://reactivex.io/rxjs/
关于javascript - 取消 JavaScript promise ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47032797/