observ

A observable value representation

npm install observ
1 downloads in the last week
45 downloads in the last month

observ

build status NPM version Davis Dependency status

browser support

NPM

A observable value representation

Example

var Observable = require("observ")

var v = Observable("initial value")
v(function onchange(newValue) {
  assert.equal(newValue, "new value")
})
v.set("new value")

var curr = v()
assert.equal(curr, "new value")

Example computed

var Observable = require("observ")
var computed = require("observ/computed")

var one = Observable(1)
var two = Observable(2)

var together = computed([one, two], function (a, b) {
  return a + b
})

assert.equal(together(), 3)
two.set(5)
assert.equal(together(), 7)

Docs

type Observable<A> := {
    () => A &
    (Function<A>) => void,
    set: (A) => void
}

observ := (A) => Observable<A>

Installation

npm install observ

Contributors

  • Raynos

MIT Licenced

npm loves you