[core/events] simplify args/kwargs detection
This commit is contained in:
parent
86fb4c38ea
commit
9cadcee844
1 changed files with 4 additions and 4 deletions
|
@ -3,7 +3,7 @@ __callbacks = {}
|
|||
|
||||
def register(event, callback, *args, **kwargs):
|
||||
cb = callback
|
||||
if len(args) + len(kwargs) > 0:
|
||||
if args or kwargs:
|
||||
cb = lambda: callback(*args, **kwargs)
|
||||
|
||||
__callbacks.setdefault(event, []).append(cb)
|
||||
|
@ -19,10 +19,10 @@ def trigger(event, *args, **kwargs):
|
|||
return False
|
||||
|
||||
for callback in cb:
|
||||
if len(args) + len(kwargs) == 0:
|
||||
callback()
|
||||
else:
|
||||
if args or kwargs:
|
||||
callback(*args, **kwargs)
|
||||
else:
|
||||
callback()
|
||||
return True
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue