I am trying to figure out the conceptual differences between an infinite Stream and an infinite Flux respectively (if there are any).
For that matter, I have come up with the following examples for an infinite Stream/Flux
@Test
public void infinteStream() {
//Prints infinite number of integers
Stream<Integer> infiniteStream = Stream.iterate(0, i -> i+1);
infiniteStream.forEach(System.out::println);
}
@Test
public void infiniteFlux() {
//Prints infinite number of date strings (every second)
Flux<LocalDateTime> localDateTimeFlux = Flux.interval(Duration.ofSeconds(1))
.map(t -> LocalDateTime.now());
localDateTimeFlux.subscribe(t -> System.out.println(t.format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"))));
}
Regarding these examples, I have the question: Is there an analog for infinteStream() with Flux (and for infinteFlux() with Stream respectively)? And, more generally, are there any differences between an infinite Stream and Flux?