Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
State Machine for Backbone. Useful for async transitions (via jQuery deferreds), and responding to state change events based on a configuration grammar.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.md
StateMachine.js

README.md

Backbone.StateMachine

State Machine for Backbone. Useful for async transitions (via jQuery deferreds), and responding to state change events based on a configuration grammar.

var fsm = new BackboneStateMachine({
    initial: 'initial',
    transitions: {
        initial: {
            transition: ['*', 'initialPending', 'initial'],

            before: function(){
                console.log('do something')
            },
            during: function (id) {

                return $.ajax();
            },
            after: function (id) {
                this.goToInitial();
            },
            cancel: function(){

            }
        }
    }
}

fsm.getState()
fsm.isValidTransition();
fsm.cancel();
fsm.initial();
fsm.next();
Something went wrong with that request. Please try again.