I use Fysom to create FSM. I want to use callbacks in another way:
TABLE = {
'initial': 'OFF',
'events': [{'name': 'load', 'src': 'OFF', 'dst': 'LOADED'},],
'callbacks': {'onload': myfunction,}}
fsm = Fysom(TABLE)
Here, if I run fsm.onload(), it will execute myfunction. Instead, I want, if I run myfunction(), it dines fsm.onload().
I looked at the script and related part:
def _enter_state(self, e):
'''
Executes the callback for onenter_state_ or on_state_.
'''
for fnname in ['onenter' + e.dst, 'on' + e.dst]:
if hasattr(self, fnname):
return getattr(self, fnname)(e)
I do not see how to change this world of code for my purpose.
Katsu source
share