npm.io
0.0.2 • Published 9 years ago

@nathanfaucett/atom

Licence
BSD-2-Clause
Version
0.0.2
Deps
2
Vulns
0
Weekly
0

Atom

clojure like atom for the browser and node.js

var Atom = require("@nathanfaucett/atom");


var atom = Atom({
  key: null
});

atom.addListener(function onChange(prev, next) {
  // use prev and next state
});

atom.update(function update(current) {
  return {
    key: "value"
  }
});
console.log(atom.get()); // { key: "value" }

atom.set({
  key: null
});
console.log(atom.get()); // { key: null }

Keywords