-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Page events allow multiple subscribers (#38)
* Update control itself when isolated Re-implement control.build() * Page events allow multiple subscribers
- Loading branch information
1 parent
c30be7a
commit f743acb
Showing
2 changed files
with
32 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class EventHandler: | ||
def __init__(self) -> None: | ||
self.__handlers = {} | ||
|
||
def handler(self, e): | ||
for h in self.__handlers.keys(): | ||
h(e) | ||
|
||
def subscribe(self, handler): | ||
self.__handlers[handler] = True | ||
|
||
def unsubscribe(self, handler): | ||
if handler in self.__handlers: | ||
self.__handlers.pop(handler) |
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