https://github.com/cmstead/jsatom
An atom implementation in common JS
https://github.com/cmstead/jsatom
Last synced: about 2 months ago
JSON representation
An atom implementation in common JS
- Host: GitHub
- URL: https://github.com/cmstead/jsatom
- Owner: cmstead
- Created: 2015-01-04T08:21:26.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-22T19:28:08.000Z (about 11 years ago)
- Last Synced: 2025-12-27T14:31:24.450Z (6 months ago)
- Language: JavaScript
- Size: 211 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
JSAtom
======
An atom implementation in Javascript.
JSAtom is an implementation of Clojure's atoms. One of the most important things to note about
atoms is they are specifically a mutable object handled with a mutator function. Any mutation is applied
to the atom only if the atom data hasn't changed during the execution of the mutator function.
To Dos
##Atom module
- [x] Create core atom module (atom.build)
- [x] Build swap function (function swap)
- [x] Implement watchers (function setWatcher)
- [ ] Return unwatch function (return from setWatcher)
- [ ] Handle assigned validator (function setValidator)
- [x] Retrieve raw value (function deref)
- [x] Compare old value and set new value (ensures old value value is still the current value and sets value)
- [ ] Fire watcher events on atom
- [ ] Remove watcher
##JFP module extension
All of the collowing functions can/will have side effects
- [x] atom (value)
- [x] compareAndSet (atom, oldValue, newValue) (can fail)
- [x] deref (atom, fn)
- [ ] setValidator (atom, fn)
- [x] setWatcher (atom, fn)
- [ ] removeWatcher(atom, watcherId)
- [x] swap (atom, fn)