这里解释了面向铁路的编程(ROP):
https://fsharpforfunandprofit.com/rop/
有没有办法使用这种模式Fluture
我可以像这样使用这两个辅助方法进行 ROP:
const bind = f => x => Future.attempt(() => f(x));
const bindAsync = f => x => Future.tryP(() => f(x));
Future.of("TEST")
.chain(bind(doThis))
.chain(bind(doThat))
.chain(bindAsync(doThisAsync))
.chain(bindAsync(doThatAsync))
.chain(bind(doAnotherThing))
.chain(bindAsync(doAnotherThingAsync))
.
.
.
有没有更好的方法来删除bind
,bindAsync
并自动进行绑定?