本文整理了Java中rx.Single.compose()
方法的一些代码示例,展示了Single.compose()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Single.compose()
方法的具体详情如下:
包路径:rx.Single
类名称:Single
方法名:compose
暂无
代码示例来源:origin: vert-x3/vertx-examples
.flatMap(updateResult -> conn.rxUpdateWithParams("INSERT INTO colors (name) VALUES (?)", new JsonArray().add("PURPLE")))
.compose(SQLClientHelper.txSingleTransformer(conn))
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void st2ToSt1() {
SingleTransformer<Integer, Integer> transformer = new SingleTransformer<Integer, Integer>() {
@Override
public Single<Integer> apply(Single<Integer> o) {
return o.map(new Function<Integer, Integer>() {
@Override
public Integer apply(Integer v) {
return v + 1;
}
});
}
};
rx.Single.just(1)
.compose(toV1Transformer(transformer))
.test()
.assertResult(2);
}
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* Generates a {@link Single} from {@link SQLConnection} operations executed inside a transaction.
*
* @param client the {@link SQLClient}
* @param sourceSupplier a user-provided function returning a {@link Single} generated by interacting with the given {@link SQLConnection}
* @param <T> the type of the item emitted by the {@link Single}
* @return a {@link Single} generated from {@link SQLConnection} operations executed inside a transaction
*/
public static <T> Single<T> inTransactionSingle(SQLClient client, Function<SQLConnection, Single<T>> sourceSupplier) {
return usingConnectionSingle(client, conn -> sourceSupplier.apply(conn).compose(txSingleTransformer(conn)));
}
代码示例来源:origin: vert-x3/vertx-rx
/**
* Generates a {@link Single} from {@link SQLConnection} operations executed inside a transaction.
*
* @param client the {@link SQLClient}
* @param sourceSupplier a user-provided function returning a {@link Single} generated by interacting with the given {@link SQLConnection}
* @param <T> the type of the item emitted by the {@link Single}
* @return a {@link Single} generated from {@link SQLConnection} operations executed inside a transaction
*/
public static <T> Single<T> inTransactionSingle(SQLClient client, Function<SQLConnection, Single<T>> sourceSupplier) {
return usingConnectionSingle(client, conn -> sourceSupplier.apply(conn).compose(txSingleTransformer(conn)));
}
代码示例来源:origin: vert-x3/vertx-rx
private Single<List<String>> inTransaction(Exception e) throws Exception {
return client.rxGetConnection().flatMap(conn -> {
return rxInsertExtraFolks(conn)
.andThen(uniqueNames(conn))
.<List<String>>collect(ArrayList::new, List::add).toSingle()
.compose(upstream -> e == null ? upstream : upstream.flatMap(names -> Single.error(e)))
.compose(SQLClientHelper.txSingleTransformer(conn))
.flatMap(names -> rxAssertAutoCommit(conn).andThen(Single.just(names)))
.doAfterTerminate(conn::close);
});
}
}
内容来源于网络,如有侵权,请联系作者删除!