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