本文整理匯總了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();
}
});
}
示例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();
});
}
示例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();
}
示例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);
}