0.0.2 • Published 8 years ago

@nathanfaucett/atom v0.0.2

Weekly downloads
1
License
BSD-2-Clause
Repository
github
Last release
8 years ago

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 }