Pligins refactor with new context and controller integration
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
from libs.singleton import Singleton
|
||||
from ..singleton import Singleton
|
||||
|
||||
from ..dto.base_event import BaseEvent
|
||||
|
||||
@@ -25,7 +25,7 @@ class ControllerBase(Singleton, EmitDispatcher):
|
||||
|
||||
|
||||
def _controller_message(self, event: BaseEvent):
|
||||
raise ControllerBaseException("Controller Base must override '_controller_message'...")
|
||||
raise ControllerBaseException("Controller Base '_controller_message' must be overridden...")
|
||||
|
||||
def set_controller_context(self, controller_context: ControllerContext):
|
||||
self.controller_context = controller_context
|
||||
|
||||
@@ -8,8 +8,4 @@ from dataclasses import dataclass, field
|
||||
|
||||
@dataclass
|
||||
class Requests:
|
||||
ui_target: str = ""
|
||||
ui_target_id: str = ""
|
||||
pass_events: bool = False
|
||||
pass_ui_objects: list = field(default_factory = lambda: [])
|
||||
bind_keys: list = field(default_factory = lambda: [])
|
||||
bind_keys: list = field(default_factory = lambda: [])
|
||||
|
||||
@@ -28,16 +28,16 @@ class EventSystem(Singleton):
|
||||
def _resume_processing_events(self):
|
||||
self._is_paused = False
|
||||
|
||||
def subscribe(self, event_type, fn):
|
||||
def subscribe(self, event_type: str, fn: callable):
|
||||
self.subscribers[event_type].append(fn)
|
||||
|
||||
def unsubscribe(self, event_type, fn):
|
||||
def unsubscribe(self, event_type: str, fn: callable):
|
||||
self.subscribers[event_type].remove(fn)
|
||||
|
||||
def unsubscribe_all(self, event_type):
|
||||
def unsubscribe_all(self, event_type: str):
|
||||
self.subscribers.pop(event_type, None)
|
||||
|
||||
def emit(self, event_type, data = None):
|
||||
def emit(self, event_type: str, data: tuple = ()):
|
||||
if self._is_paused and event_type != "resume_event_processing":
|
||||
return
|
||||
|
||||
@@ -51,7 +51,7 @@ class EventSystem(Singleton):
|
||||
else:
|
||||
fn()
|
||||
|
||||
def emit_and_await(self, event_type, data = None):
|
||||
def emit_and_await(self, event_type: str, data: tuple = ()):
|
||||
if self._is_paused and event_type != "resume_event_processing":
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user