observ-transform

1.0.0 • Public • Published

observ-transform

Observable transform (with args) based on observ pattern.

Install via npm

$ npm install observ-transform

API

var Transform = require('observ-transform')

// helpers
var connect = require('observ-transform/connect')
var send = require('observ-transform/send')
var when = require('observ-transform/when')

var transform = Transform(func, args)

Specify args as an Array of strings (to add observ properties to transform), or an Object containing observable values.

Returns an observable transform object.

transform()

Returns the current transformed value.

transform.set(value)

Set the value to transform via func.

var release = transform(listener)

Listen for changes.

transform.input()

Return current input value.

Example

Using String Args

var Transform = require('observ-transform')
var obs = Tranform(function (input, args) {
  return input * args.multiply + args.add
}, ['multiply', 'add'])
obs.multiply.set(3)
obs.add.set(24)
obs.set(100)
t.same(obs(), 324)

Using Object Args

var obs = Transform(function (input, args) {
  return input * args.multiply + args.add
}, {
  multiply: Observ(3),
  add: Observ(24)
})
obs.set(100)
t.same(obs(), 324)

Package Sidebar

Install

npm i observ-transform

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • mmckegg