2017-05-04 5 views
0

발리처럼 개조 2 태그로 특정 요청을 취소 할 수있는 방법이 있습니까? 발리에서 우리는 이것을함으로써 요청을 취소 할 수 있습니다.개조 중 태그 별 요청을 취소하는 방법 2?

sRequestQueue = Volley.newRequestQueue(appContext); 


public void enqueueRequest(Request req) { 
    sRequestQueue.add(req); 
} 


public void cancelTaggedRequests(String tag) { 
    sRequestQueue.cancelAll(tag); 
} 

Retrofit 2.0과 비슷한 방법이 있습니까?

답변

0

당신은 call.cancel();

또 다른 방법은 RxJava를 사용하여 구독을 생성하고 존경 요청을 취소 구독을 호출하여 요청을 취소 할 수 있습니다.

if (subscription != null && !subscription.isUnsubscribed()) { 
    subscription.unsubscribe(); 
}