Add support for the DataUpdateCoordinator to not automatically update (#37734)

This commit is contained in:
Rohan Kapoor 2020-07-10 15:48:20 -07:00 committed by GitHub
parent 52939865fa
commit 0db8140c13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 5 deletions

View file

@ -30,7 +30,7 @@ class DataUpdateCoordinator:
logger: logging.Logger,
*,
name: str,
update_interval: timedelta,
update_interval: Optional[timedelta] = None,
update_method: Optional[Callable[[], Awaitable]] = None,
request_refresh_debouncer: Optional[Debouncer] = None,
):
@ -91,6 +91,9 @@ class DataUpdateCoordinator:
@callback
def _schedule_refresh(self) -> None:
"""Schedule a refresh."""
if self.update_interval is None:
return
if self._unsub_refresh:
self._unsub_refresh()
self._unsub_refresh = None