feat: + subscribe

This commit is contained in:
莘权 马 2023-11-02 11:51:10 +08:00
parent 8572fa8ecd
commit 660f788683
3 changed files with 68 additions and 14 deletions

View file

@ -134,6 +134,10 @@ class Role(Named):
def _watch(self, actions: Iterable[Type[Action]]):
"""Listen to the corresponding behaviors"""
tags = [get_class_name(t) for t in actions]
self.subscribe(tags)
def subscribe(self, tags: Set[str]):
"""Listen to the corresponding behaviors"""
self._rc.watch.update(tags)
# check RoleContext after adding watch actions
self._rc.check(self._role_id)