From 8553cd834c1558dd59087657134c7f99306e8818 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 10 Aug 2022 08:59:20 -0400 Subject: [PATCH] Common: Improve readability of PyPubSubEventQueue.publish() --- monkey/common/event_queue/pypubsub_event_queue.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/monkey/common/event_queue/pypubsub_event_queue.py b/monkey/common/event_queue/pypubsub_event_queue.py index 17670e8f8..ff98a85f3 100644 --- a/monkey/common/event_queue/pypubsub_event_queue.py +++ b/monkey/common/event_queue/pypubsub_event_queue.py @@ -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)