mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-23 01:31:32 +00:00
Refactor FSMManager.(un)?subscribe() family of methods to accept lists
This commit is contained in:
parent
5d7223779a
commit
770123310a
@ -60,11 +60,12 @@ class FSMManager:
|
|||||||
try: self.fsm.trigger(trigger, message=message)
|
try: self.fsm.trigger(trigger, message=message)
|
||||||
except AttributeError: log.debug('FSM failed to execute nonexistent trigger: "{}"'.format(trigger))
|
except AttributeError: log.debug('FSM failed to execute nonexistent trigger: "{}"'.format(trigger))
|
||||||
|
|
||||||
def subscribe_predicate(self, trigger, predicate):
|
def subscribe_predicate(self, trigger, *predicates):
|
||||||
self.trigger_predicates[trigger].append(predicate)
|
self.trigger_predicates[trigger].extend(predicates)
|
||||||
|
|
||||||
def unsubscribe_predicate(self, trigger, predicate):
|
def unsubscribe_predicate(self, trigger, *predicates):
|
||||||
self.trigger_predicates[trigger].remove(predicate)
|
self.trigger_predicates[trigger] = [predicate for predicate in self.trigger_predicates[trigger]
|
||||||
|
not in predicates]
|
||||||
|
|
||||||
|
|
||||||
class FSMUpdater:
|
class FSMUpdater:
|
||||||
|
Loading…
Reference in New Issue
Block a user