merge multiple
jethrolarson opened this issue · comments
I was banging my head against a problem for a while before realizing that flyd.merge is binary. For some reason I expected it to merge all arguments.
flyd.merge(a, b, c)
I wish js would throw on these kind of errors...
I guess this is more feedback than a bug. Close if you think it's not a problem.
What about adding a mergeAll
? It takes a list of streams and merges them all?
Seems reasonable.
On Sat, Oct 17, 2015, 2:22 AM Simon Friis Vindum notifications@github.com
wrote:
What about adding a mergeAll? It takes a list of streams and merges them
all?—
Reply to this email directly or view it on GitHub
#66 (comment).
I was just thinking this... We could also use a clone.
flyd.clone = function(s) {
return flyd.stream([s], function() {
return s()
})
}
flyd.mergeAll = function(list) {
if (list.length === 0) {
return flyd.stream()
} else if (list.length === 1) {
return flyd.clone(list[0])
} else {
return R.reduce(flyd.merge, list[0], list.slice(1))
}
}
I was also just looking for something like this. 👍
here is a quick attempt: #79
This issue is solved thanks to the mergeAll
module contributed by @jordalgo.