1.0.0 • Published 8 years ago

state-pipe v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

state-pipe Build Status

Declare a set of pipes and transformations for passing observable state in an application

Install

$ npm install --save state-pipe

Usage

var StatePipe = require('state-pipe')
var pipe = StatePipe({
  'foo.bar': [times10, 'fooDest']
})

function times10 (value) {
  return value * 10
}

var state = Struct({
  foo: Struct({
    bar: Observ(1)
  }),
  fooDest: Observ()
})


state.fooDest()
//=> 10

state.foo.bar.set(2)
state.fooDest()
//=> 20

API

StatePipe(data) -> function

Returns an unlisten function.

data

Required
Type: object

Key-value mappings between state properties. The keys represent the source observables while the values can be:

  • a string (the destination observable)
  • an array where the last entry is the destination observable and the previous entries are functions that will transform the source value

License

MIT © Ben Drucker