Giter Site home page Giter Site logo

Comments (2)

oldratlee avatar oldratlee commented on August 15, 2024

能否提供操作多个入参的工具类方法?

@huhaosumail 目前(v1.0.0-Alpha7)实现支持了 多个输入并返回多个输入结果的方法,如allResultsOf/allTupleOfmostResultsOfSuccess/mostTupleOfSuccessallResultsOfFastFail/allTupleOfFastFail

但这些方法,输入的类型是CompletionStage,而不是action类型(如RunnableConsumerFunction)。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.

oldratlee avatar oldratlee commented on August 15, 2024

@huhaosumailv1.0.0-Alpha10版本中,实现了:

  • implement the multi-actions methods in CompletableFutureUtils ✨ 🚀
    • mSupplyAsync/mSupplyFastFailAsync/mSupplyMostSuccessAsync
    • mRunAsync/mRunFastFailAsync
    • thenMApplyAsync/thenMApplyFastFailAsync/thenMApplyMostSuccessAsync
    • thenMAcceptAsync/thenMAcceptFastFailAsync
    • thenMRunAsync/thenMRunFastFailAsync

还要继续补全实现相应的方法:

  • 相应的tupleOf*方法(已由@huhaosumail 实现 ♥️🎉)
  • Cffu类中对应的方法(已由@huhaosumail 实现 ♥️🎉)
  • Kotlin Extension中对应的方法

from cffu.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.