[core/event] Initial commit of simplistic event engine

This commit is contained in:
Tobias Witek 2020-02-16 14:27:17 +01:00
parent 26ae63b5ad
commit c1df1686c1
2 changed files with 59 additions and 0 deletions

13
core/event.py Normal file
View file

@ -0,0 +1,13 @@
callbacks = {}
def register(event, callback, *args, **kwargs):
callbacks.setdefault(event, []).append(
lambda: callback(*args, **kwargs)
)
def trigger(event):
for callback in callbacks.get(event, []):
callback()
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4