I am trying to understand the effect of repeatedly subscribe to a Mono with a delay of 1 second and stop subscribing based on a certain condition, I have this line of code
Mono.just(UUID.randomUUID())
.map(uuid -> uuid.toString())
.doOnNext(uuid -> System.out.println(uuid))
.repeatWhen(completed -> completed.delayElements(Duration.ofMillis(1000)))
.takeUntil(uuid -> uuid.startsWith("1234"))
.subscribe();
What I expect from that line, is to keep printing a random UUID every one second, until it generate one starting with 1234 and then stop. But it just print just on UUID and then exits. How do I achieve that using this line ?