coffee_state_machine
Advanced tools
Comparing version 0.3.1 to 0.3.2
{ | ||
"name": "coffee_state_machine", | ||
"description": "a finite state machine made in and for coffeescript (javascript)", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"url": "https://github.com/spearwolf/coffee_state_machine", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -26,1 +26,48 @@ # coffee_state_machine [![Build Status](https://secure.travis-ci.org/spearwolf/coffee_state_machine.png "Build Status")](http://travis-ci.org/spearwolf/coffee_state_machine) | ||
* written in 100% [CoffeeScript](http://coffeescript.org/) | ||
#### cheat sheet | ||
``` coffeescript | ||
sm = state_machine 'state', (state, event, transition) -> | ||
state.initial 'foo' | ||
state 'plah', -> | ||
one: -> yes | ||
two: -> no | ||
state 'bar', parent: 'plah', enter: (-> "onEnterBar"), exit: (-> "onExitBar"), -> | ||
one: -> no | ||
two: -> yes | ||
event 'boom', -> | ||
transition | ||
plah: foo | ||
bar: plah | ||
transition.from 'foo', to: 'bar', if: -> true, unless: -> false | ||
event 'bang', -> | ||
transition.from ['foo', 'bar'], to: 'bar', action: (oldState, newState) -> "..." | ||
transition.all except: 'bar', only: ['foo'], to: 'plah' | ||
sm.two = 2 | ||
sm.boom three: 42 | ||
sm.three is 42 # => yes | ||
sm.two() # => yes | ||
sm.state is 'bar' # => yes | ||
sm.is_state('plah') # => yes | ||
``` |
Sorry, the diff of this file is not supported yet
58580
73