Common: Improve readability of PyPubSubEventQueue.publish()

This commit is contained in:
Mike Salvatore 2022-08-10 08:59:20 -04:00
parent 1d7b498290
commit 8553cd834c
1 changed files with 8 additions and 4 deletions

View File

@ -32,12 +32,16 @@ class PyPubSubEventQueue(IEventQueue):
self._pypubsub_publisher.subscribe(listener=subscriber, topicName=tag)
def publish(self, event: AbstractEvent):
# publish to event type's topic
self._pypubsub_publisher.sendMessage(event.__name__, event=event)
self._publish_to_all_events_topic(event)
self._publish_to_type_topic(event)
self._publish_to_tags_topic(event)
# publish to all events' topic
def _publish_to_all_events_topic(self, event: AbstractEvent):
self._pypubsub_publisher.sendMessage(INTERNAL_ALL_EVENT_TYPES_TOPIC, event=event)
# publish to tags' topics
def _publish_to_type_topic(self, event: AbstractEvent):
self._pypubsub_publisher.sendMessage(event.__name__, event=event)
def _publish_to_tags_topic(self, event: AbstractEvent):
for tag in event.tags:
self._pypubsub_publisher.sendMessage(tag, event=event)