🐛 移除liteyuki.channel.on_receive() wrapper对async和sync function的判断冗余代码

This commit is contained in:
snowy 2024-07-27 10:21:31 +08:00
parent 39a9c39924
commit 0fb5b84392

View File

@ -157,16 +157,10 @@ class Channel:
""" """
if receiver is None: if receiver is None:
for func in self._on_receive_funcs: for func in self._on_receive_funcs:
if is_coroutine_callable(func): run_coroutine(func(data))
run_coroutine(func(data))
else:
func(data)
else: else:
for func in self._on_receive_funcs_with_receiver.get(receiver, []): for func in self._on_receive_funcs_with_receiver.get(receiver, []):
if is_coroutine_callable(func): run_coroutine(func(data))
run_coroutine(func(data))
else:
func(data)
def __iter__(self): def __iter__(self):
return self return self