Can someone help me understand what is going on here with Flux's takeUntil operator?
Flux.just(1, 2, 3, 4, 5)
.takeUntil { it < 4 }
.map { println("Flux:$it") }
.subscribe()
In the console, the only thing that is printed is:
Flux:1
I expected to see
Flux:1
Flux:2
Flux:3
Why do I only see one element?
CodePudding user response:
Please, note that you are using the takeUntil() operator:
Relay values from this
Fluxuntil the givenPredicatematches. This includes the matching data (unliketakeWhile(java.util.function.Predicate<? super T>)).
Please, note: «until»:
until the given
Predicatematches
To achieve the desired behavior, please, consider using the takeWhile() operator instead:
Relay values from this
Fluxwhile a predicate returns TRUE for the values (checked before each value is delivered). This only includes the matching data (unliketakeUntil(java.util.function.Predicate<? super T>)).
