jakesgordon/javascript-state-machine — pull request #10 by cboone (2011-11-27 04:06:20+00:00)
Title: Custom event error callbacks

Hi Jake,

I’ve been dealing with similar problems to those described by @alanhogan in #3, so I went ahead and implemented a simple version of the solution you described. You can specify (an optional) `error` callback function when you create your state machine, which gets called if you try to trigger an event that is not allowed in the current state -- instead of throwing an exception.

I also added some QUnit test coverage for this new feature, and wrote up a simple explanation for the README.

If this approach isn’t quite what you had in mind, let me know, and I’ll tweak it. I need this feature for a project I’m working on, and it might as well be done in a way that works more generally.

Thanks,
Chris