diff options
Diffstat (limited to 'README')
-rw-r--r-- | README | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -185,7 +185,8 @@ Dynamically generated event names Sometimes you have to compute the name of an event you want to trigger on the fly. Instead of relying on `getattr` you can use the `trigger` method, which takes -a string (the event name) as a parameter. +a string (the event name) as a parameter, followed by any arguments/keyword +arguments you want to pass to the event method. This is also arguably better if you're not sure if the event exists at all (FysomError vs. AttributeError, see below). @@ -200,7 +201,7 @@ This is also arguably better if you're not sure if the event exists at all {'name': 'calm', 'src': 'red', 'dst': 'yellow'}, {'name': 'clear', 'src': 'yellow', 'dst': 'green'} ] }) - fsm.trigger('warn') # equivalent to fsm.warn() + fsm.trigger('warn', msg="danger") # equivalent to fsm.warn(msg="danger") fsm.trigger('unknown') # FysomError, event does not exist fsm.unknown() # AttributeError, event does not exist |