T - the type of itempublic class UniRepeat<T> extends Object
| Modifier and Type | Method and Description |
|---|---|
Multi<T> |
atMost(long times)
Generates a stream, containing the items from the upstream
Uni, resubscribed at most times times. |
Multi<T> |
indefinitely()
Generates an unbounded stream, indefinitely resubscribing to the
Uni. |
Multi<T> |
until(Predicate<T> predicate)
Generates a stream, containing the items from the upstream
Uni, resubscribed until the given predicate
returns true. |
Multi<T> |
whilst(Predicate<T> predicate)
Generates a stream, containing the items from the upstream
Uni, resubscribed while the given predicate
returns true. |
public Multi<T> indefinitely()
Uni.
Note that this enforces:
The produced Multi contains the items emitted by the upstream Uni. After every emission,
another subscription is performed on the Uni, and the item is then propagated. If the Uni
fires a failure, the failure is propagated. If the Uni fires an empty items, it resubscribes.
public Multi<T> atMost(long times)
Uni, resubscribed at most times times.
Note that this enforces:
The produced Multi contains the items emitted by the upstream Uni. After every emission,
another subscription is performed on the Uni, and the item is then propagated. If the Uni
fires a failure, the failure is propagated. If the Uni fires an empty items, it resubscribes.
This method is named atMost because the repeating re-subscription can be stopped if the subscriber
cancels its subscription to the produced Multi.
times - the number of re-subscription, must be strictly positive, 1 is equivalent to Uni.toMulti()Multi containing the items from the upstream Uni, resubscribed at most times
times.public Multi<T> until(Predicate<T> predicate)
Uni, resubscribed until the given predicate
returns true. The predicate is called on the item produced by the Uni. If it does not pass, the
item is not propagated downstream and the repetition is stopped.
Unlike whilst(Predicate), the checked item is only propagated downstream if it passed the predicate.
For example, if you use an API returning "null" or an empty set once you reach the end, you can stop the
repetition when this case is detected.
The predicate is not called on null item. If you want to intercept this case, use a sentinel item.
If the Uni propagates a failure, the failure is propagated and the repetition stopped.public Multi<T> whilst(Predicate<T> predicate)
Uni, resubscribed while the given predicate
returns true.
The uni is subscribed at least once. The item is checked. Regardless the result of the predicate, the item
is propagated downstream. If the test passed, the repetition continues, otherwise the repetition is stopped.
Unlike until(Predicate), the checked item is propagated downstream regardless if it passed the predicate.
For example, if you use a Rest API specifying the "next page", you can stop the repetition when the "next page"
is absent, while still propagating downstream the current page.
The predicate is not called on null item. If you want to intercept this case, use a sentinel item.
If the Uni propagates a failure, the failure is propagated and the repetition stopped.Copyright © 2019–2020 SmallRye. All rights reserved.