version of scan that takes Uni as second arg? #1298
Replies: 2 comments
-
maybe a code example will help? the lambda's in listOfLambdas have a signature like this Right now I'm trying to use scan(), but it doesn't flatten the Uni returned by each lambda into a result I can feed into next one final var multi = Multi.createFrom().iterable(listOfLambdas);
// doesn't work because scan() won't flatten Unis. previousLamdaReturnValue ends up being Uni<previousLamdaReturnValue>
multi.onItem().scan(()->Uni.createFrom().item(initialValue), (previousLamdaReturnValue,lambda)->()->lambda.apply(previousLamdaReturnValue)); this is existing signature of scan(Supplier<S> initialStateProducer,
BiFunction<S,? super T,S> accumulator) Where I need something that does accumulation like scan(Supplier<Uni<S>> initialStateProducer,
BiFunction<S,? super T,<Uni<S>> asyncAccumulator) Essentially, I need a I'm working on an HTTP framework that needs to apply a list of requestHandler lambdas to a request in order. With each handler taking the output of the previous handler as it's input. This is so each handler can manipulate the request then pass it on to the next. Ex: first handler checks MAC of request, the second one decrypts it, third one decompresses. Much like how chained route handlers work in Vert.X, or request interceptor in Spring Boot |
Beta Was this translation helpful? Give feedback.
-
Hello!
I need to run a list of lambda functions sequentially, in order, with each one using the output of previous lambda as it's input.
Scan is very close to what I need, but the operation each lambda does is async and returns a Uni that needs to be resolved before feeding the result into the next lambda. I need something like scan that also does flatMap
Is there an existing operator I can use to do this?
Beta Was this translation helpful? Give feedback.
All reactions