I read from an Instagram blog that with folly future, you can do:
doIO1(io1Input)
.then([..](Data io1Result) {
return doIO2(io1Result);
})
.then([..](Data io2Result){
return doIO3(io2Result);
})
.then([..](Data io3Result){
...
})
.onError([](const std::exception& e){
// handle errors in io1, io2 or io3
})
And I am curious how folly future makes it work. I read some folly future source code. In the then() method, it creates internally a promise/future pair. My question is how folly associates this internal promise/future with the return value of the callback so that the chain of then() can continue?