mirror of
https://github.com/onyx-and-iris/voicemeeter-compact.git
synced 2024-11-22 04:40:55 +00:00
fd30a5ef0d
merge subject classes. modify obsevers callback ensure sunvalley theme loaded only once. minor version bump
37 lines
841 B
Python
37 lines
841 B
Python
class Subject:
|
|
"""Adds support for observers"""
|
|
|
|
def __init__(self):
|
|
"""list of current observers"""
|
|
|
|
self._observers = list()
|
|
|
|
def notify(self, modifier=None):
|
|
"""run callbacks on update"""
|
|
|
|
[o.on_update(modifier) for o in self._observers]
|
|
|
|
def add(self, observer):
|
|
"""adds an observer to observables"""
|
|
|
|
if observer not in self._observers:
|
|
self._observers.append(observer)
|
|
|
|
def remove(self, observer):
|
|
"""removes an observer from observables"""
|
|
|
|
try:
|
|
self._observers.remove(observer)
|
|
except ValueError:
|
|
pass
|
|
|
|
def get(self) -> list:
|
|
"""returns the current observables"""
|
|
|
|
return self._observers
|
|
|
|
def clear(self):
|
|
"""clears the observables list"""
|
|
|
|
self._observers.clear()
|