本文整理匯總了Java中io.reactivex.Completable.fromAction方法的典型用法代碼示例。如果您正苦於以下問題:Java Completable.fromAction方法的具體用法?Java Completable.fromAction怎麽用?Java Completable.fromAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.reactivex.Completable
的用法示例。
在下文中一共展示了Completable.fromAction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: remove
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable remove(K... keys) {
return Completable.fromAction(() -> {
try (Jedis jedis = pool.getResource()) {
String[] fullKeys = new String[keys.length];
for (int i = 0; i < keys.length; i++) {
fullKeys[i] = buildKey(keys[i]);
}
jedis.del(fullKeys);
} catch (Exception e) {
LOG.error("Could not write to Redis", e);
throw new ServiceException(HttpStatus.SC_INTERNAL_SERVER_ERROR, e);
}
});
}
示例2: storeToMap
import io.reactivex.Completable; //導入方法依賴的package包/類
private Completable storeToMap(final int orderID,
final IOrder order) {
return Completable.fromAction(() -> {
orderByID.put(orderID, order);
logger.debug("Stored Zorro order with ID " + orderID + " to repository.");
});
}
示例3: markAsRead
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable markAsRead(int accountId, int peerId) {
return Completable.fromAction(() -> {
final Uri uri = MessengerContentProvider.getMessageContentUriFor(accountId);
final String where = MessageColumns.PEER_ID + " = ? AND " + MessageColumns.OUT + " = ?";
final String[] args = {String.valueOf(peerId), "0"};
markAsRead(uri, where, args);
});
}
示例4: evictCredentials
import io.reactivex.Completable; //導入方法依賴的package包/類
private Completable evictCredentials(AuthenticationCredentials credentials) {
if (PasswordCredentials.class.isAssignableFrom(credentials.getClass())) {
credentials = new CachedPasswordCredentials((PasswordCredentials) credentials);
} else if (AuthorizationToken.class.isAssignableFrom(credentials.getClass())) {
credentials = new CachedAuthorizationToken((AuthorizationToken) credentials);
} else {
throw new ServiceException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Invalid credentials type");
}
final AuthenticationCredentials cachedCredentails = credentials;
return Completable.fromAction(() -> cacheManager.evictForGroup(authenticationCacheGroupName, cachedCredentails));
}
示例5: removeLink
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable removeLink(int accountId, String id) {
return Completable.fromAction(() -> {
final Uri uri = MessengerContentProvider.getFaveLinksContentUriFor(accountId);
final String where = FaveLinksColumns.LINK_ID + " LIKE ?";
final String[] args = {id};
getContentResolver().delete(uri, where, args);
});
}
示例6: removeUser
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable removeUser(int accountId, int userId) {
return Completable.fromAction(() -> {
final Uri uri = MessengerContentProvider.getFaveUsersContentUriFor(accountId);
final String where = FaveUsersColumns._ID + " = ?";
final String[] args = {String.valueOf(userId)};
getContentResolver().delete(uri, where, args);
});
}
示例7: deleteAsync
import io.reactivex.Completable; //導入方法依賴的package包/類
/**
* Asynchronously deletes a file handle. Requires security to be set.
*
* @see #delete()
*/
public Completable deleteAsync() {
return Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
delete();
}
});
}
示例8: set
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable set(K key, V value) {
return Completable.fromAction(() -> {
String valueToWrite = serialize(value);
try (Jedis jedis = pool.getResource()) {
jedis.setex(buildKey(key), ttlSeconds, valueToWrite);
} catch (Exception e) {
LOG.error("Could not write to Redis", e);
throw new ServiceException(HttpStatus.SC_INTERNAL_SERVER_ERROR, e);
}
});
}
示例9: changeTitle
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable changeTitle(int accountId, int peedId, String title) {
return Completable.fromAction(() -> {
final Uri uri = MessengerContentProvider.getDialogsContentUriFor(accountId);
ContentValues cv = new ContentValues();
cv.put(DialogsColumns.TITLE, title);
getContentResolver().update(uri, cv, DialogsColumns._ID + " = ?", new String[]{String.valueOf(peedId)});
});
}
示例10: remove
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public synchronized Completable remove(String collection, String key) {
Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE);
Objects.requireNonNull(key, NULL_KEY_MESSAGE);
return Completable.fromAction(() -> {
Map<String, Map<String, Object>> collectionData = documents.computeIfAbsent(collection, k -> new LinkedHashMap<>());
collectionData.remove(key);
});
}
示例11: overwriteAsync
import io.reactivex.Completable; //導入方法依賴的package包/類
/**
* Asynchronously replace the content of an existing file handle. Requires security to be set.
* Does not update the filename or MIME type.
*
* @see #overwrite(String)
*/
public Completable overwriteAsync(final String pathname) {
return Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
overwrite(pathname);
}
});
}
示例12: demo5
import io.reactivex.Completable; //導入方法依賴的package包/類
private void demo5() {
Completable completable = Completable.fromAction(() -> {
log("Let's do something");
});
completable.subscribe(() -> {
log("Finished");
}, throwable -> {
log(throwable);
});
Single.just("One item")
.subscribe((item) -> {
log(item);
}, (throwable) -> {
log(throwable);
});
Maybe.empty();
Maybe.just("Item")
.subscribe(s -> {
log("On Success: " + s);
});
Maybe.just("Item")
.subscribe(s -> {
log("On Success: " + s);
}, throwable -> log("error"));
Maybe.just("Item")
.subscribe(
s -> log("success: " + s),
throwable -> log("error"),
() -> log("onComplete")
);
}
示例13: setPassword
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable setPassword(Wallet wallet, String password) {
return Completable.fromAction(() -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
KS.put(context, wallet.address, password);
} else {
try {
PasswordManager.setPassword(wallet.address, password, context);
} catch (Exception e) {
throw new ServiceErrorException(
ServiceErrorException.KEY_STORE_ERROR);
}
}
});
}
示例14: logoutCloudAsync
import io.reactivex.Completable; //導入方法依賴的package包/類
/**
* Asynchronously logs out from specified cloud.
*
* @see #logoutCloud(String)
*/
public Completable logoutCloudAsync(final String providerName) {
return Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
logoutCloud(providerName);
}
});
}
示例15: invalidatePost
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable invalidatePost(int accountId, int postVkid, int postOwnerId) {
return Completable.fromAction(() -> {
Uri uri = getPostsContentUriFor(accountId);
String where = PostsColumns.POST_ID + " = ? AND " + PostsColumns.OWNER_ID + " = ?";
String[] args = {String.valueOf(postVkid), String.valueOf(postOwnerId)};
getContentResolver().delete(uri, where, args);
});
}