mirror of
https://github.com/Brandon-Rozek/website.git
synced 2025-03-13 01:16:06 +00:00
Added callable check
This commit is contained in:
parent
6b750e4c1d
commit
68e4211310
1 changed files with 4 additions and 0 deletions
|
@ -16,6 +16,8 @@ class Application:
|
|||
def __init__(self):
|
||||
self.callbacks = []
|
||||
def subscribe(self, func):
|
||||
if not callable(func):
|
||||
raise ValueError("Argument func must be callable.")
|
||||
self.callbacks.append(func)
|
||||
return func
|
||||
def emit(self, message):
|
||||
|
@ -57,6 +59,8 @@ class Application:
|
|||
self.callbacks = defaultdict(list)
|
||||
def on(self, event, func=None):
|
||||
def subscribe(func):
|
||||
if not callable(func):
|
||||
raise ValueError("Argument func must be callable.")
|
||||
self.callbacks[event].append(func)
|
||||
return func
|
||||
if func is None:
|
||||
|
|
Loading…
Reference in a new issue