kee-frame-sample
kee-frame-sample copied to clipboard
FSM: stop/start behaviour clarification
Hi.
When stopping and starting FSMs, shouldn't the FSM state be restarted according to the :start directive?
Example:
(require '[kee-frame.fsm.alpha :as fsm])
(def my-http-request-fsm
{:id :my-http-request
:start ::loading
:stop ::loaded
:fsm {::loading {[::fsm/on-enter] {:dispatch [[:contact-the-server]]}
[:server-responded] {:to ::loaded}
[:default-on-failure] {:to ::loading-failed}}
::loading-failed {[::fsm/timeout 10000] {:to ::loading}}}})
If I dispatch ::fsm/start my-http-request-fsm again, shouldn't :state become ::loading?
TBH, I have not tried this with actual :stop condition as I'm stopping my FSM manually. But I'm seeking to essentially reset the FSM via :start/:stop, and if I dspatch :stop and then :start, the :state remains whatever it was on when :stop was dispatched.
I was expecting state to be reset on :stop, but maybe I shouldn't?