1.0.5 • Published 8 years ago

simplejsstatemachine v1.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

Installation

npm install simplejsstatemachine

Usage

Simple state machine implemented in javascript, distributable as node package.

var module = require('simplejsstatemachine');

//create state machine to represent review state.
var reviewstate = module.create('initial');

//State transition from 'initial' to 'draft' if 'publish' is triggered.
reviewstate.configure('initial').allow('publish', 'draft');

//State transition from 'draft' to 'submitted' if 'submitted' is triggered.
reviewstate.configure('draft').allow('submitted','submitted');

//register any callback that is invoked when state transition occurs.
reviewstate.on('stateChange', function(stateChange){
	console.log('Current state : ' +  stateChange.currentStateName);
	console.log('Previous state : ' +  stateChange.previousStateName);
});

//fire trigger.
reviewstate.fire('publish');

License

Licensed under MIT

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago