From 91cbf23d3acc3e44b333cac95d45575bc7bacb1c Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Mon, 3 Jan 2022 18:49:09 +0100 Subject: Added basic event notification capabilities, first event --- notifier.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 notifier.py (limited to 'notifier.py') diff --git a/notifier.py b/notifier.py new file mode 100644 index 0000000..1a68c56 --- /dev/null +++ b/notifier.py @@ -0,0 +1,15 @@ + +class Notifier: + PLAYING_STATE_EVENT = 0 + + def __init__(self): + self._callbacks = dict() + + def registerCallback(self, event, callback): + if event not in self._callbacks: + self._callbacks[event] = list() + self._callbacks[event].append(callback) + + def notify(self, event): + for callback in self._callbacks.get(event, list()): + callback() -- cgit v1.2.3