2020-02-16 14:27:17 +01:00
|
|
|
|
|
|
|
callbacks = {}
|
|
|
|
|
|
|
|
def register(event, callback, *args, **kwargs):
|
|
|
|
callbacks.setdefault(event, []).append(
|
|
|
|
lambda: callback(*args, **kwargs)
|
|
|
|
)
|
|
|
|
|
2020-02-22 13:42:44 +01:00
|
|
|
def clear():
|
|
|
|
callbacks.clear()
|
|
|
|
|
2020-02-16 14:27:17 +01:00
|
|
|
def trigger(event):
|
|
|
|
for callback in callbacks.get(event, []):
|
|
|
|
callback()
|
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|