Comments (2)
能否提供操作多个入参的工具类方法?
@huhaosumail 目前(v1.0.0-Alpha7
)实现支持了 多个输入并返回多个输入结果的方法,如allResultsOf
/allTupleOf
、mostResultsOfSuccess
/mostTupleOfSuccess
、allResultsOfFastFail
/allTupleOfFastFail
。
但这些方法,输入的类型是CompletionStage
,而不是action
类型(如Runnable
、Consumer
、Function
)。CompletionStage
类型参数。
在常见简单业务场景的使用中,并不方便与安全。期望的使用方式,代码示例如下:
////////////////////////////////////////
// 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
from cffu.
@huhaosumail 在v1.0.0-Alpha10
版本中,实现了:
- implement the
multi-actions
methods inCompletableFutureUtils
✨ 🚀
mSupplyAsync
/mSupplyFastFailAsync
/mSupplyMostSuccessAsync
mRunAsync
/mRunFastFailAsync
thenMApplyAsync
/thenMApplyFastFailAsync
/thenMApplyMostSuccessAsync
thenMAcceptAsync
/thenMAcceptFastFailAsync
thenMRunAsync
/thenMRunFastFailAsync
还要继续补全实现相应的方法:
- 相应的
tupleOf*
方法(已由@huhaosumail 实现♥️ 🎉) Cffu
类中对应的方法(已由@huhaosumail 实现♥️ 🎉)Kotlin Extension
中对应的方法
from cffu.
Related Issues (14)
- good job 👍 HOT 1
- v1.0 project management HOT 2
- Some API suggestions:) HOT 2
- `CompletableFutureUtils` provides the biz exception extraction method
- Provides the logging config(logging uncaught exception)
- implement `anySuccess/any(Complete) M* methods` in `CompletableFutureUtils`/`CffuFactory`/`Cffu` HOT 1
- implement `Kotlin Extension methods` of `M* methods`
- implement the nice methods of `Guava ListenableFuture`
- integrate `Guava ListenableFuture`
- implement the `catching()` of `Guava ListenableFuture`
- implement `successfulAsList` method of `Guava ListenableFuture`
- add retry support for CompletableFuture HOT 2
- Consider removing methods using common pool
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cffu.