-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change API to be a global event registry that can handle multiple hoo…
…ks per event
- Loading branch information
1 parent
0ce9364
commit d710205
Showing
3 changed files
with
32 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Events: | ||
def __init__(self): | ||
self.pre_process = [] | ||
self.post_process = [] | ||
|
||
|
||
# Singleton | ||
EVENTS = Events() | ||
|
||
|
||
def register(name, callback): | ||
if hasattr(EVENTS, name): | ||
getattr(EVENTS, name).append(callback) | ||
else: | ||
raise Exception(f"{name} is not a valid pyqs event.") | ||
|
||
|
||
def get_events(): | ||
return EVENTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters