【发布时间】:2019-11-08 14:22:34
【问题描述】:
这里解释了面向铁路的编程(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并自动进行绑定?
【问题讨论】:
标签: javascript functional-programming fluture