Hi, newbie here, I have been looking the documentation, I can't figure out how to make this work.
let say, I have two futures, f1 and f2, I want to combine them in a new future or stream and process them in the order in which they were resolved, without the need to wait for all to be complete.
for example, f2.join(f1), will not works because this wait till both futures are done.
I am looking for something more like this
combine([f1, f2]).map(|result|{
do_computation;
return future
}).map(|another_result|{
another computation;
return result
}).collect()
@vitalyd, that worked just perfect, the real use case is about made multiples queries to different servers, and parse the response to json as they come. I also wanted to understand more about futures and how can I compose pipelines with them
In case you’re wondering, the issue with your initial version using futures_unordered is the map() - this function just translates/maps the result of each item in the stream but crucially doesn’t return something that’s a future itself. Or rather, you can return something that’s a future but the framework doesn’t "hook it up" - nothing drives it to completion. So the res.body().concat2()... future was created but immediately dropped, and no output was generated.