mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Small speed up to async_listen (#103307)
Avoid constructing an inner function each time we call async_listen and use a partial which holds a reference to the function body with new args instead of making another full function
This commit is contained in:
parent
062b510ec0
commit
dca72c598e
@ -1176,12 +1176,9 @@ class EventBus:
|
||||
self, event_type: str, filterable_job: _FilterableJobType
|
||||
) -> CALLBACK_TYPE:
|
||||
self._listeners.setdefault(event_type, []).append(filterable_job)
|
||||
|
||||
def remove_listener() -> None:
|
||||
"""Remove the listener."""
|
||||
self._async_remove_listener(event_type, filterable_job)
|
||||
|
||||
return remove_listener
|
||||
return functools.partial(
|
||||
self._async_remove_listener, event_type, filterable_job
|
||||
)
|
||||
|
||||
def listen_once(
|
||||
self,
|
||||
|
Loading…
x
Reference in New Issue
Block a user