We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
目前CompletableFuture提供的都是最多两个入参的方法。
CompletableFuture
CompletableFuture<Map> future1 = CompletableFuture.supplyAsync(() -> { Map result = Maps.newHashMap(); result.put("j", "j"); return result; }); future1.thenAccept((Map map) -> { System.out.println("thenAccept:" + map.get("j")); }); future1.thenCombine(CompletableFuture.completedFuture("123"), (map, s) -> { System.out.println("thenCombine:" + map.get("j")); System.out.println(s); return "yy"; });
能否提供操作多个入参的工具类方法? 例如多个入参的消费accept/combine。
accept
combine
anySuccess/any(Complete) M* methods
CompletableFutureUtils
CffuFactory
Cffu
Kotlin Extension methods
M* methods
The text was updated successfully, but these errors were encountered:
能否提供操作多个入参的工具类方法?
@huhaosumail 目前(v1.0.0-Alpha7)实现支持了 多个输入并返回多个输入结果的方法,如allResultsOf/allTupleOf、mostResultsOfSuccess/mostTupleOfSuccess、allResultsOfFastFail/allTupleOfFastFail。
v1.0.0-Alpha7
allResultsOf
allTupleOf
mostResultsOfSuccess
mostTupleOfSuccess
allResultsOfFastFail
allTupleOfFastFail
但这些方法,输入的类型是CompletionStage,而不是action类型(如Runnable、Consumer、Function)。CompletionStage类型参数。
CompletionStage
action
Runnable
Consumer
Function
在常见简单业务场景的使用中,并不方便与安全。期望的使用方式,代码示例如下:
//////////////////////////////////////// // Demo 1 //////////////////////////////////////// // 目前功能的使用方式,awkward~ 😖 CompletableFuture.allResultsOf( CompletableFuture.supplyAsync(() -> 42), CompletableFuture.supplyAsync(() -> 52), CompletableFuture.supplyAsync(() -> 62) ).thenAccept(System.out::println); // <=> // 期望的使用方式,fresh and cool 😋 CompletableFuture.mSupplyAsync( () -> 42, () -> 52, () -> 62 ).thenAccept(System.out::println); // output: [42, 52, 62] //////////////////////////////////////// // Demo 2 //////////////////////////////////////// // 目前功能的使用方式,awkward~ 😖 CompletableFuture.supplyAsync(() -> 42).thenCompose(v -> allResultsOf( CompletableFuture.supplyAsync(() -> v + 1), CompletableFuture.supplyAsync(() -> v + 2), CompletableFuture.supplyAsync(() -> v + 3) ) ).thenAccept(System.out::println); // <=> // 期望的使用方式,fresh and cool 😋 CompletableFuture.supplyAsync(() -> 42).thenMApplyAsync( v -> v + 1, v -> v + 2, v -> v + 3 ).thenAccept(System.out::println); // output: [43, 44, 45]
实现输入参数是action类型的多参数方法,后续版本高优 ❤️ 😄 @huhaosumail
Sorry, something went wrong.
@huhaosumail 在v1.0.0-Alpha10版本中,实现了:
v1.0.0-Alpha10
implement the multi-actions methods in CompletableFutureUtils ✨ 🚀 mSupplyAsync/mSupplyFastFailAsync/mSupplyMostSuccessAsync mRunAsync/mRunFastFailAsync thenMApplyAsync/thenMApplyFastFailAsync/thenMApplyMostSuccessAsync thenMAcceptAsync/thenMAcceptFastFailAsync thenMRunAsync/thenMRunFastFailAsync
multi-actions
mSupplyAsync
mSupplyFastFailAsync
mSupplyMostSuccessAsync
mRunAsync
mRunFastFailAsync
thenMApplyAsync
thenMApplyFastFailAsync
thenMApplyMostSuccessAsync
thenMAcceptAsync
thenMAcceptFastFailAsync
thenMRunAsync
thenMRunFastFailAsync
还要继续补全实现相应的方法:
tupleOf*
Kotlin Extension
huhaosumail
No branches or pull requests
目前
CompletableFuture
提供的都是最多两个入参的方法。能否提供操作多个入参的工具类方法?
例如多个入参的消费
accept
/combine
。implement rest related methods
anySuccess/any(Complete) M* methods
inCompletableFutureUtils
/CffuFactory
/Cffu
#191Kotlin Extension methods
ofM* methods
#192The text was updated successfully, but these errors were encountered: