Common: Pass event_data to subscribers when publishing in PyPubSubEventQueue

This commit is contained in:
Shreya Malviya 2022-08-10 14:02:53 +05:30
parent 32efa0f0f2
commit f26beb6464
1 changed files with 5 additions and 3 deletions

View File

@ -32,13 +32,15 @@ class PyPubSubEventQueue(IEventQueue):
self._pypubsub_publisher.subscribe(listener=subscriber, topicName=tag) self._pypubsub_publisher.subscribe(listener=subscriber, topicName=tag)
def publish(self, event: AbstractEvent): def publish(self, event: AbstractEvent):
event_data = {"event": event}
# publish to event type's topic # publish to event type's topic
event_type_name = event.__name__ event_type_name = event.__name__
self._pypubsub_publisher.sendMessage(event_type_name, event) self._pypubsub_publisher.sendMessage(event_type_name, **event_data)
# publish to all events' topic # publish to all events' topic
self._pypubsub_publisher.sendMessage(INTERNAL_ALL_EVENT_TYPES_TOPIC, event) self._pypubsub_publisher.sendMessage(INTERNAL_ALL_EVENT_TYPES_TOPIC, **event_data)
# publish to tags' topics # publish to tags' topics
for tag in event.tags: for tag in event.tags:
self._pypubsub_publisher.sendMessage(tag, event) self._pypubsub_publisher.sendMessage(tag, **event_data)