More info: http://blog.dreasgrech.com/2011/10/state-manager-in-javascript.html
Source: https://github.com/dreasgrech/statemanager-js
var state = stateManager();Setting the mutual exclusive states:
for (i = 0, j = 9; i < 5; i++, j--) {
state.mutex(i, j);
}
Setting the global change hook:
state.onStateChanged(function (state, value) {
addLog("Button " + state + " was switched " + (value ? "on" : "off"), "black");
setButton(state, value);
});
Setting the two custom hooks on buttons 4 and 9:
state.onStateChanged(4, function (value) {
addLog("The hook from button 4 has been called", "red");
});
state.onStateChanged(9, function (value) {
addLog("The hook from button 9 has been called", "blue");
});