i not understand why the code:
Multi.createFrom().ticks().every(Duration.ofSeconds(10)).onItem().invoke(
x -> return "example"
).subscribe().with(System.out::println);
-> print: 1,2,3,.. (every 10 sec)
not produce the same output like this:
Multi.createFrom().ticks().every(Duration.ofSeconds(10)).map(
x -> return "example"
).subscribe().with(System.out::println);
-> print example,example .. (every 10 sec)
why? It's a quarkus project with dependecy:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mutiny</artifactId>
</dependency>
thanks
The
invokemethod is called when an item (or failure if used afteronFailure()) arrives but does not send its result downstream. It's just to peek at the event, not to change it.The
mapmethod is called when an item arrives and transforms that event. The result of the method is sent downstream.References:
map: https://smallrye.io/smallrye-mutiny/latest/tutorials/transforming-items/invoke: https://smallrye.io/smallrye-mutiny/latest/tutorials/observing-events