Common: Implement subscribe_tags() in PypubsubEventQueue

This commit is contained in:
Shreya Malviya 2022-08-08 12:03:17 +05:30
parent bb76410bac
commit 414e8127ed
1 changed files with 6 additions and 8 deletions

View File

@ -18,18 +18,16 @@ class PypubsubEventQueue(IEventQueue):
PypubsubEventQueue._subscribe_type(event_type, subscriber) PypubsubEventQueue._subscribe_type(event_type, subscriber)
def _subscribe_type(event_type: AbstractEvent, subscriber: Callable[..., Any]): def _subscribe_type(event_type: AbstractEvent, subscriber: Callable[..., Any]):
# pypubsub.pub.subscribe needs a string as the topic/event name
event_type_name = event_type.__name__ event_type_name = event_type.__name__
pub.subscribe(subscriber, event_type_name) pub.subscribe(listener=subscriber, topicName=event_type_name)
def subscribe_tags(self, tags: Sequence[str], subscriber: Callable[..., Any]): def subscribe_tags(self, tags: Sequence[str], subscriber: Callable[..., Any]):
""" for tag in tags:
Subscribes a subscriber to all specified event tags PypubsubEventQueue._subscribe_tag(tag, subscriber)
:param tags: Event tags to which the subscriber should subscribe def _subscribe_tag(tag: str, subscriber: Callable[..., Any]):
:param subscriber: Callable that should subscribe to events pub.subscribe(listener=subscriber, topicName=tag)
"""
pass
def publish(self, event: AbstractEvent, data: Any): def publish(self, event: AbstractEvent, data: Any):
""" """