You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But for your convenience, can easily ask if a state is active at any time:
141
+
Or you can check if a state is active at any time:
131
142
132
143
```py
133
-
>>>traffic_light.green.is_active
144
+
>>>sm.green.is_active
134
145
False
135
146
136
-
>>>traffic_light.yellow.is_active
147
+
>>>sm.yellow.is_active
137
148
True
138
149
139
-
>>>traffic_light.red.is_active
150
+
>>>sm.red.is_active
140
151
False
141
152
142
153
```
143
154
144
155
Easily iterate over all states:
145
156
146
157
```py
147
-
>>> [s.id for s intraffic_light.states]
158
+
>>> [s.id for s insm.states]
148
159
['green', 'red', 'yellow']
149
160
150
161
```
151
162
152
163
Or over events:
153
164
154
165
```py
155
-
>>> [t.name for t intraffic_light.events]
156
-
['cycle', 'go', 'slowdown', 'stop']
166
+
>>> [t.name for t insm.events]
167
+
['cycle']
157
168
158
169
```
159
170
160
171
Call an event by its name:
161
172
162
173
```py
163
-
>>>traffic_light.cycle()
174
+
>>>sm.cycle()
164
175
Don't move.
165
176
'Running cycle from yellow to red'
166
177
167
178
```
168
179
Or send an event with the event name:
169
180
170
181
```py
171
-
>>>traffic_light.send('cycle')
182
+
>>>sm.send('cycle')
172
183
Go ahead!
173
184
'Running cycle from red to green'
174
185
175
-
>>>traffic_light.green.is_active
186
+
>>>sm.green.is_active
176
187
True
177
188
178
189
```
179
-
You can't run a transition from an invalid state:
190
+
191
+
You can pass arbitrary positional or keyword arguments to the event, and
192
+
they will be propagated to all actions and callbacks using something similar to dependency injection. In other words, the library will only inject the parameters declared on the
0 commit comments