Permalink
Browse files

big cleanup and trim-down

  • Loading branch information...
1 parent 67601e0 commit 3a80a904d52e3e4e243c0e3728d42538e4e14082 @joshwnj committed Aug 19, 2012
Showing with 277 additions and 11,507 deletions.
  1. +28 −21 README.md
  2. +0 −9,266 examples/jquery-1.7.1.js
  3. +0 −536 examples/mustache.js
  4. +0 −33 examples/photos.css
  5. +0 −28 examples/photos.html
  6. +0 −185 examples/photos.js
  7. +0 −55 examples/screens.css
  8. +0 −28 examples/screens.html
  9. +0 −110 examples/screens.js
  10. +56 −0 examples/switch.css
  11. +19 −0 examples/switch.html
  12. +14 −0 examples/switch.js
  13. +0 −977 examples/underscore.js
  14. +4 −4 package.json
  15. +155 −0 statelet.js
  16. +0 −195 states.js
  17. +1 −69 tests/index.js
View
@@ -1,39 +1,46 @@
-# States
+# Statelet
-[![Build Status](https://secure.travis-ci.org/joshwnj/States.png)](http://travis-ci.org/joshwnj/States)
+[![Build Status](https://secure.travis-ci.org/joshwnj/statelet.png)](http://travis-ci.org/joshwnj/statelet)
Instead of this:
```js
-if (SomeObject.is_ready) {
- // ...
+if (is_ready) {
+ // do the thing
+}
+else {
+ // put into a queue and execute when is_ready=true
}
```
Do this:
```js
-SomeObject.is_ready.when(true, function () {
- // ....
+is_ready.when(true, function () {
+ // do the thing
});
```
-## Watching State
+## Logic Gates
```js
-var state = new State;
-
-// notify whenever the value changes
-state.watch(function (value) { ... });
-
-// notify when the value changes to something specific
-state.when(value, function () { ... });
+var burger = new State();
+var fries = new State();
+var meal_is_ready = new State();
+
+function onMealChange () {
+ var burger_ready = burger.get() === 'flipped';
+ var fries_ready = fries.get() === 'fried';
+ meal_is_ready.set(burger_ready && fries_ready);
+}
+burger.watch(onMealChange);
+fries.watch(onMealChange);
+meal_is_ready.when(true, function () {
+ console.log('ding ding!');
+});
+```
-// notify whenever a certain transition occurs
-state.onTransition(from, to, function () { ... });
+## To do
-// wildcards work for transitions
-state.onTransition('*', to, function (from, to) { ... });
-state.onTransition(from, '*', function (from, to) { ... });
-state.onTransition('*', '*', function (from, to) { ... });
-```
+ * make sure examples have decent cross-browser support
+ * more examples
Oops, something went wrong.

0 comments on commit 3a80a90

Please sign in to comment.