nodename / stately

Stately: Statecharts in Clojure/Script
MIT License
58 stars 8 forks source link

entry-actions should fire after transition action #4

Open jiangts opened 7 years ago

jiangts commented 7 years ago

Suppose you're given the following configuration

{
:states {:fsm/A {:entry-actions [[:fsm/action1]]
                 :exit-actions [[:fsm/action2]]}}
:transitions {[:fsm/A :event] {:target :fsm/A
                               :actions [[:fsm/action3]]}}
...
}

When the transition :event is fired on state :fsm/A, the expected order of actions dispatched should be action2, action3, action1. In the given implementation, the order is action2, action1, action3.

nodename commented 7 years ago

I don't agree. The transition is supposed to conceptually take zero time; in other words, the system is not in a valid state if you access it between states, and there is no context in which an action can take place. I believe it is standard for the transition action to take place in the context of the target state, although it would be valid (but not equivalent) if the other choice (context of the source state) were made consistently throughout.