[英]CombineLatest in Highland.js
我的天真的實現如下:
var combineLatest = function(...streams) {
var _streams = streams.map(
(s, i) => s.map((x) => {return {[i]: x}})
)
return H(_streams).merge().scan1(H.extend).filter((obj) => {
return Object.keys(obj).length === streams.length
}).map(obj =>
_(obj).pairs().reduce(
(res, [key, val]) => {
res[key] = val
return res
},
[]
)
)
}
combineLatest(users, photos).each((x) => console.log(x))
但我不擔心這種解決方案的性能
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.