flyd icon indicating copy to clipboard operation
flyd copied to clipboard

liftAllObj

Open ccorcos opened this issue 10 years ago • 1 comments

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)

ccorcos avatar Dec 04 '15 02:12 ccorcos

I dig it, why not make a PR for it as a module?

c-dante avatar Apr 21 '16 19:04 c-dante