forked from p15670423/monkey
Island: Accept any kwargs in IIslandEventQueue.publish()
This commit is contained in:
parent
a76273fa0d
commit
b4c8ac7242
|
@ -1,6 +1,5 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
from . import IslandEventSubscriber
|
from . import IslandEventSubscriber
|
||||||
|
|
||||||
|
@ -29,12 +28,12 @@ class IIslandEventQueue(ABC):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def publish(self, topic: IslandEventTopic, event: Any = None):
|
def publish(self, topic: IslandEventTopic, **kwargs):
|
||||||
"""
|
"""
|
||||||
Publishes an event topic with the given data
|
Publishes an event topic with the given data
|
||||||
|
|
||||||
:param topic: Event topic to publish
|
:param topic: Event topic to publish
|
||||||
:param event: Event data to publish
|
:param **kwargs: Event data to publish
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
from pubsub.core import Publisher
|
from pubsub.core import Publisher
|
||||||
|
|
||||||
|
@ -18,11 +17,11 @@ class PyPubSubIslandEventQueue(IIslandEventQueue):
|
||||||
topic_name = topic.name # needs to be a string for pypubsub
|
topic_name = topic.name # needs to be a string for pypubsub
|
||||||
self._pypubsub_publisher_wrapper.subscribe(topic_name, subscriber)
|
self._pypubsub_publisher_wrapper.subscribe(topic_name, subscriber)
|
||||||
|
|
||||||
def publish(self, topic: IslandEventTopic, event: Any = None):
|
def publish(self, topic: IslandEventTopic, **kwargs):
|
||||||
topic_name = topic.name # needs to be a string for pypubsub
|
topic_name = topic.name # needs to be a string for pypubsub
|
||||||
logger.debug(f"Publishing {topic_name} event")
|
logger.debug(f"Publishing {topic_name} event")
|
||||||
|
|
||||||
if event is None:
|
# if event is None:
|
||||||
self._pypubsub_publisher_wrapper.publish(topic_name)
|
# self._pypubsub_publisher_wrapper.publish(topic_name)
|
||||||
else:
|
# else:
|
||||||
self._pypubsub_publisher_wrapper.publish(topic_name, event=event)
|
self._pypubsub_publisher_wrapper.publish(topic_name, **kwargs)
|
||||||
|
|
Loading…
Reference in New Issue