當前位置: 首頁>>代碼示例>>Java>>正文


Java SingleEmitter.setCancellable方法代碼示例

本文整理匯總了Java中io.reactivex.SingleEmitter.setCancellable方法的典型用法代碼示例。如果您正苦於以下問題:Java SingleEmitter.setCancellable方法的具體用法?Java SingleEmitter.setCancellable怎麽用?Java SingleEmitter.setCancellable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.reactivex.SingleEmitter的用法示例。


在下文中一共展示了SingleEmitter.setCancellable方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override
public final void subscribe(SingleEmitter<T> emitter) throws Exception {
    final GoogleApiClient apiClient = createApiClient(new ApiClientConnectionCallbacks(emitter));

    try {
        apiClient.connect();
    } catch (Throwable ex) {
        emitter.onError(ex);
    }

    emitter.setCancellable(new Cancellable() {
        @Override
        public void cancel() throws Exception {
            if (apiClient.isConnected()) {
                RxLocationSingleOnSubscribe.this.onUnsubscribed(apiClient);
            }

            apiClient.disconnect();
        }
    });
}
 
開發者ID:TechIsFun,項目名稱:RxJava2-weather-example,代碼行數:22,代碼來源:RxLocationSingleOnSubscribe.java

示例2: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override
public final void subscribe(SingleEmitter<T> emitter) throws Exception {
    final GoogleApiClient apiClient = createApiClient(new ApiClientConnectionCallbacks(emitter));

    try {
        apiClient.connect();
    } catch (Throwable ex) {
        emitter.onError(ex);
    }

    emitter.setCancellable(() -> {
        if (apiClient.isConnected()) {
            onUnsubscribed(apiClient);
        }

        apiClient.disconnect();
    });
}
 
開發者ID:florent37,項目名稱:RxGps,代碼行數:19,代碼來源:RxLocationSingleOnSubscribe.java

示例3: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(SingleEmitter<GoogleSignIn.SignInAccount> emitter) throws Exception {
    this.emitter = emitter;
    initGoogleApiClient();

    emitter.setCancellable(() -> {
        AndroidSchedulers.mainThread().scheduleDirect(() -> {
            disconnect();
            activity = null;
        });
    });

    act();
}
 
開發者ID:yosriz,項目名稱:RxGooglePhotos,代碼行數:15,代碼來源:GoogleSignInOnSubscribeBase.java

示例4: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(SingleEmitter<DataSnapshot> emitter) throws Exception {
  ValueEventSingle listener = new ValueEventSingle(emitter);
  emitter.setCancellable(listener.cancellable(query));
  query.addListenerForSingleValueEvent(listener);
}
 
開發者ID:ashdavies,項目名稱:rx-firebase,代碼行數:7,代碼來源:SingleValueEventOnSubscribe.java


注:本文中的io.reactivex.SingleEmitter.setCancellable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。