1
我写了一个函数,它返回一个promise列表(在ramda中的代码),然后我必须用Promise.all()来解决所有的promise并将其发回给承诺链。将Promise.all([promise of list])转换为ramda
例如,
// Returns Promise.all that contains list of promises. For each endpoint we get the data from a promised fn getData().
const getInfos = curry((endpoints) => Promise.all(
pipe(
map(getData())
)(endpoints))
);
getEndpoints() //Get the list of endpoints, Returns Promise
.then(getInfos) //Get Info from all the endpoints
.then(resp => console.log(JSON.stringify(resp))) //This will contain a list of responses from each endpoint
promiseFn
是返回Promise的函数。
我该如何最好地将此函数转换为完整的Ramda,并使用pipeP或其他东西?有人可以推荐吗?
你能否更详细地解释这是什么一样,也许有更明确的变量名?例如,外部'pipe'做什么?它看起来不相关。 'promiseFn'做什么? –
@ScottSauyet我已经更新了这个问题,如果您需要更多信息,请告诉我。谢谢 – geek
我不知道你的意思是“*打破使用咖喱函数的想法*” – Bergi