Backbone-FSM
Finite-State Machine for Backbone views and models. Browser and Node.js compatible.
Installation
Bower
bower install backbone-fsm
Old school
Include lib/backbone-fsm.js
into your page.
Node.js
npm install backbone-fsm
Usage
Initialization
FSM
comes with mixin
method. You have to extend this
during initialization.
var Foo = BackboneView;
Transitions
You can define transitions
and defaultState
:
var Foo = BackboneView;
To make a transition run transitionTo("secondState")
.
During transition:
transition:start
event is emitedonTransitionName
callback is called (if defined).transition:stop
event is emited
Example
Backbone-FSM live example: http://jsfiddle.net/fragphace/Zc6Gx/
Tests
For server-side tests:
npm test
Browser tests can be found in test/browser.html
.
Tested under:
- IE 7+
- FF 15+
- Chrome 22+
Development
- Generate JS files -
make coffee
- Watch mode -
make watch