Related to this question to take a string from a Mono I think I have finally got how to take a String
out of a Flux<String>
like this:
Flux<String> rates = controller.getRate(json);
String myRate = rates.next().subscribe(System.out::print);
However, this is causing a type mismatch cannot convert from Disposable to String
What am I getting wrong?
To clarify, it's for testing - I need an internal String value. So if I have a Flux<String>
of strings: one
, two
, three
then I want to set another String to value one
String s = ...
If I try
String s = rates.doOnNext(System.out::print);
Then I get a type mismatch: cannot convert from Flux<String> to String
If I try
String s = next().flatMap(System.out::print);
Then I get a type mismatch: cannot convert from Mono<Object> to String