Paginated API with cursor to Multi #952
IsSkyfalls
started this conversation in
General
Replies: 1 comment 1 reply
-
@jponge do you think can we use the internal context support for this? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let's say I have an API with the following schema:
and to retrieve the next page, you do GET /api/foo/cursor-to-next-page.
With the current
Multi.createBy().repeating()
function, by default, each Uni/CompletionStage is initialized without any context of the last result, unless you store that information somewhere:If we need to limit the number of pages, this becomes more complex as we can't use
UniRepeat.atMost(5)
with `.whilst(Predicate).My workround is to use a Tuple2 to hold both the AtomicReference and AtomicInteger as a counter.
Another solution would be to use an variable in the function that the Multi is created, but I'm not sure about the performance issue that will cause(context switching maybe), and it still looks bad.
It would be good if the api allows
MultiRepetition.uni()
to have the result produced by the last Uni.Beta Was this translation helpful? Give feedback.
All reactions