@PostMapping("/rxjava2-single") @SuppressWarnings("deprecation") public io.reactivex.Completable createWithRxJava2Single(@RequestBody io.reactivex.Single<Person> single) { return single.map(persons::add).toCompletable(); }
@PostMapping("/rxjava2-observable") @SuppressWarnings("deprecation") public io.reactivex.Completable createWithRxJava2Observable( @RequestBody io.reactivex.Observable<Person> observable) { return observable.toList().doOnSuccess(persons::addAll).toCompletable(); }
@PostMapping("/flowable") @SuppressWarnings("deprecation") public io.reactivex.Completable createWithFlowable(@RequestBody Flowable<Person> flowable) { return flowable.toList().doOnSuccess(persons::addAll).toCompletable(); } }
@Override public Completable writeDescriptor(@NonNull final UUID serviceUuid, @NonNull final UUID characteristicUuid, @NonNull final UUID descriptorUuid, @NonNull final byte[] data) { return discoverServices() .flatMap(new Function<RxBleDeviceServices, SingleSource<BluetoothGattDescriptor>>() { @Override public SingleSource<BluetoothGattDescriptor> apply(RxBleDeviceServices rxBleDeviceServices) { return rxBleDeviceServices.getDescriptor(serviceUuid, characteristicUuid, descriptorUuid); } }) .doOnSuccess(new Consumer<BluetoothGattDescriptor>() { @Override public void accept(BluetoothGattDescriptor bluetoothGattDescriptor) throws Exception { bluetoothGattDescriptor.setValue(data); } }) .toCompletable(); }
@Test @SuppressWarnings("deprecation") public void toCompletable() { Single.just(1) .toCompletable() .test() .assertResult(); Single.error(new TestException()) .toCompletable() .test() .assertFailure(TestException.class); }
/** * Returns the sku name and account kind. * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @return a Single which performs the network request upon subscription. */ public Completable getAccountInfoAsync(Context context) { return getAccountInfoWithRestResponseAsync(context) .toCompletable(); } }
/** * Returns the sku name and account kind. * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @return a Single which performs the network request upon subscription. */ public Completable getAccountInfoAsync(Context context) { return getAccountInfoWithRestResponseAsync(context) .toCompletable(); } }
/** * Returns the sku name and account kind. * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @return a Single which performs the network request upon subscription. */ public Completable getAccountInfoAsync(Context context) { return getAccountInfoWithRestResponseAsync(context) .toCompletable(); } }
/** * Returns the sku name and account kind. * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @return a Single which performs the network request upon subscription. */ public Completable getAccountInfoAsync(Context context) { return getAccountInfoWithRestResponseAsync(context) .toCompletable(); } }
/** * Returns the sku name and account kind. * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @return a Single which performs the network request upon subscription. */ public Completable getAccountInfoAsync(Context context) { return getAccountInfoWithRestResponseAsync(context) .toCompletable(); } }
/** * Returns the sku name and account kind. * * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @return a Single which performs the network request upon subscription. */ public Completable getAccountInfoAsync(Context context) { return getAccountInfoWithRestResponseAsync(context) .toCompletable(); } }
@Override public Completable delete(String todoId) { return client.rxUpdateWithParams(SQL_DELETE, new JsonArray().add(todoId)) .toCompletable(); }
@SuppressWarnings("unchecked") @Override public <T> T fromJson(Single<Reader> req, Class<? super T> container, Class<?> type) { if (Completable.class.equals(container)) return (T) req.doOnSuccess(this::consume).toCompletable(); if (Single.class.equals(container)) return (T) req.map(reader -> { if (Reader.class.equals(type)) return reader; if (String.class.equals(type)) return readAsString(reader); return gson.fromJson(reader, type); }); if (Observable.class.equals(container)) return (T) req.toObservable() .flatMapIterable(n -> () -> new ParseArrayIterator<>(n, type)); throw new IllegalArgumentException("unsupported type " + container); }
@Override public WriteStream<Buffer> drainHandler(Handler<Void> handler) { if (this.buffer.length() < writeQueueMaxSize) { handler.handle(null); } else { this.bufferChanged$.filter(len -> len < writeQueueMaxSize).firstOrError().toCompletable().subscribe(() -> handler.handle(null)); } return this; }
@Override public Completable toCompletable() { return Completable.defer(() -> invoke().rxSetHandler() .toCompletable()); }
public <T> Completable apply(Consumer<? super Connection> consumer) { return member().doOnSuccess(member -> { try { consumer.accept(member.value()); } finally { member.checkin(); } }).toCompletable(); }
public <T> Completable apply(Consumer<? super Connection> consumer) { return member().doOnSuccess(member -> { try { consumer.accept(member.value()); } finally { member.checkin(); } }).toCompletable(); }
public static void deleteBlob(BlockBlobURL blockBlobURL) { logInfo("Start deleting file %s...", blockBlobURL.toURL()); blockBlobURL.delete(null, null, null) .toCompletable() .doOnComplete(() -> logInfo("Blob %s is deleted.", blockBlobURL.toURL())) .doOnError(error -> logError("Failed to delete blob %s with error %s.", blockBlobURL.toURL(), error.getMessage())) .blockingAwait(); }
@Override public Completable deregisterPipeline(String name) { String fullname = installationPrefix() + name; return client.deregisterPlugin(fullname).async() .doOnSuccess(response -> { if (log.isDebugEnabled()) { log.debug("Deregistered pipeline {" + fullname + "} response: {" + response.toString() + "}"); } }).toCompletable() .onErrorResumeNext(ignore404) .compose(withTimeoutAndLog("Removed pipeline {" + fullname + "}", true)); }
Completable updateUserName(String name) { return cacheProvider.read() .map(user -> { user.setName(name); return user; }) .compose(cacheProvider.replace()) .toCompletable(); }