flyd
flyd copied to clipboard
liftAllObj
I have a suggestion for lifting an object of streams.
liftAllObj = (signals) ->
labeled = ([name, stream]) ->
flyd.map(
(value) -> {"#{name}": value}
stream
)
streams = R.pipe(
R.toPairs
R.map(labeled)
)(signals)
reducer = (acc, next) ->
flyd.lift(R.merge, acc, next)
R.reduce(reducer, R.head(streams), R.tail(streams))
obj =
x: flyd.stream(1)
y: flyd.stream(2)
z: flyd.stream(2)
s = liftAllObj(obj)
flyd.on(console.log.bind(console), s)
obj.x(10)
obj.y(20)
obj.z(30)
I dig it, why not make a PR for it as a module?