mirror of
https://github.com/Brandon-Rozek/website.git
synced 2025-03-13 07:12:03 +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):
|
def __init__(self):
|
||||||
self.callbacks = []
|
self.callbacks = []
|
||||||
def subscribe(self, func):
|
def subscribe(self, func):
|
||||||
|
if not callable(func):
|
||||||
|
raise ValueError("Argument func must be callable.")
|
||||||
self.callbacks.append(func)
|
self.callbacks.append(func)
|
||||||
return func
|
return func
|
||||||
def emit(self, message):
|
def emit(self, message):
|
||||||
|
@ -57,6 +59,8 @@ class Application:
|
||||||
self.callbacks = defaultdict(list)
|
self.callbacks = defaultdict(list)
|
||||||
def on(self, event, func=None):
|
def on(self, event, func=None):
|
||||||
def subscribe(func):
|
def subscribe(func):
|
||||||
|
if not callable(func):
|
||||||
|
raise ValueError("Argument func must be callable.")
|
||||||
self.callbacks[event].append(func)
|
self.callbacks[event].append(func)
|
||||||
return func
|
return func
|
||||||
if func is None:
|
if func is None:
|
||||||
|
|
Loading…
Reference in a new issue