jakesgordon/javascript-state-machine — Issue #14: transition from a state to itself should call event callbacks
Author: oxplot
Created: 2011-12-29 23:44:26+00:00
State: open

Currently, it is possible to define an event from and to the same state. However, firing that event will not call any callbacks.
Logically, we are not leaving the current state nor entering another one, so calling state callbacks (onleavestate, onenterstate) is meaningless. However, we are firing an event and expect something to happen as result of it. I think it makes sense to fire onbeforeevent and onafterevent (or just the latter) in this situation.

My use case:
I have a SM with couple of states, each of which maintain an internal SM. Events on the top level SM can trigger events internal to each state. Hence, there could be events firing on a single state of the top level SM which only affects SM internal to that state. If the original event doesn't call and callbacks, there would be no way to trigger anything else.