Common: Modify IEventQueue to not have any static methods

This commit is contained in:
Shreya Malviya 2022-08-09 14:35:24 +05:30
parent 390757f9cb
commit 585b1ca408
1 changed files with 11 additions and 9 deletions

View File

@ -1,4 +1,4 @@
from abc import ABC, abstractstaticmethod from abc import ABC, abstractmethod
from typing import Any, Callable from typing import Any, Callable
from common.events import AbstractEvent from common.events import AbstractEvent
@ -9,8 +9,8 @@ class IEventQueue(ABC):
Manages subscription and publishing of events Manages subscription and publishing of events
""" """
@abstractstaticmethod @abstractmethod
def subscribe_all(subscriber: Callable[[AbstractEvent], None]): def subscribe_all(self, subscriber: Callable[[AbstractEvent], None]):
""" """
Subscribes a subscriber to all events Subscribes a subscriber to all events
@ -19,8 +19,10 @@ class IEventQueue(ABC):
pass pass
@abstractstaticmethod @abstractmethod
def subscribe_type(event_type: AbstractEvent, subscriber: Callable[[AbstractEvent], None]): def subscribe_type(
self, event_type: AbstractEvent, subscriber: Callable[[AbstractEvent], None]
):
""" """
Subscribes a subscriber to the specifed event type Subscribes a subscriber to the specifed event type
@ -30,8 +32,8 @@ class IEventQueue(ABC):
pass pass
@abstractstaticmethod @abstractmethod
def subscribe_tag(tag: str, subscriber: Callable[[AbstractEvent], None]): def subscribe_tag(self, tag: str, subscriber: Callable[[AbstractEvent], None]):
""" """
Subscribes a subscriber to the specified event tag Subscribes a subscriber to the specified event tag
@ -41,8 +43,8 @@ class IEventQueue(ABC):
pass pass
@abstractstaticmethod @abstractmethod
def publish(event: AbstractEvent, data: Any): def publish(self, event: AbstractEvent, data: Any):
""" """
Publishes an event with the given data Publishes an event with the given data