develop #11

Merged
itdominator merged 36 commits from develop into master 2023-09-19 01:11:24 +00:00
2 changed files with 7 additions and 5 deletions
Showing only changes of commit 9e7dbb4245 - Show all commits

View File

@ -6,10 +6,6 @@ import faulthandler
import traceback import traceback
from setproctitle import setproctitle from setproctitle import setproctitle
import tracemalloc
tracemalloc.start()
# Lib imports # Lib imports
import gi import gi
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')

View File

@ -18,6 +18,12 @@ class EventSystem:
def subscribe(self, event_type, fn): def subscribe(self, event_type, fn):
self.subscribers[event_type].append(fn) self.subscribers[event_type].append(fn)
def unsubscribe(self, event_type, fn):
self.subscribers[event_type].remove(fn)
def unsubscribe_all(self, event_type):
self.subscribers.pop(event_type, None)
def emit(self, event_type, data = None): def emit(self, event_type, data = None):
if event_type in self.subscribers: if event_type in self.subscribers:
for fn in self.subscribers[event_type]: for fn in self.subscribers[event_type]:
@ -29,8 +35,8 @@ class EventSystem:
else: else:
fn() fn()
# NOTE: Should be used when signal has only one listener and vis-a-vis
def emit_and_await(self, event_type, data = None): def emit_and_await(self, event_type, data = None):
""" NOTE: Should be used when signal has only one listener and vis-a-vis """
if event_type in self.subscribers: if event_type in self.subscribers:
for fn in self.subscribers[event_type]: for fn in self.subscribers[event_type]:
if data: if data: