2017-10-31 7 views
1

약속 나는 다음과 같은 코드가 있습니다취소 자바 스크립트 내가 구글 JS 폐쇄 라이브러리 <a href="https://developers.google.com/closure/library/" rel="nofollow noreferrer">https://developers.google.com/closure/library/</a></p> <p>을 사용하고

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 초마다 repeates을. 나는 js 코드를 디버깅 할 때 나는이 문 this.reloadGridPromise_.cancel('[INFO]Canceling');이 실행되는 것을 볼, 구글 크롬 개발자 도구

enter image description here

에 다음과 같은 요청을 볼 수 있습니다. 그러나 Chrome 개발자 도구에서 요청이 변경된 것을 볼 수 없습니다.

구글 clousre 약속 https://google.github.io/closure-library/api/goog.Promise.html

은이 방법이있을 건가요?

+0

시도해보십시오. this.reloadGridPromise_.cancel ('[INFO] Canceling'); –

답변

0

약속을 취소 할 수 없습니다. 요청을 취소하지 않으려면 약속 대신 Obesrvers를 사용해야합니다. 그래서보세요 : http://reactivex.io/rxjs/