mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Type debounce (#3167)
This commit is contained in:
parent
b9f86f735b
commit
cb7048db23
@ -4,8 +4,14 @@
|
||||
// be triggered. The function will be called after it stops being called for
|
||||
// N milliseconds. If `immediate` is passed, trigger the function on the
|
||||
// leading edge, instead of the trailing.
|
||||
export default function debounce(func, wait, immediate) {
|
||||
// tslint:disable-next-line: ban-types
|
||||
export const debounce = <T extends Function>(
|
||||
func: T,
|
||||
wait,
|
||||
immediate = false
|
||||
): T => {
|
||||
let timeout;
|
||||
// @ts-ignore
|
||||
return function(...args) {
|
||||
// tslint:disable:no-this-assignment
|
||||
// @ts-ignore
|
||||
@ -23,4 +29,4 @@ export default function debounce(func, wait, immediate) {
|
||||
func.apply(context, args);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ import {
|
||||
} from "../../../common/dom/setup-leaflet-map";
|
||||
import computeStateDomain from "../../../common/entity/compute_state_domain";
|
||||
import computeStateName from "../../../common/entity/compute_state_name";
|
||||
import debounce from "../../../common/util/debounce";
|
||||
import { debounce } from "../../../common/util/debounce";
|
||||
import parseAspectRatio from "../../../common/util/parse-aspect-ratio";
|
||||
import computeDomain from "../../../common/entity/compute_domain";
|
||||
|
||||
|
@ -31,7 +31,7 @@ import "../../components/ha-paper-icon-button-arrow-prev";
|
||||
import "../../components/ha-icon";
|
||||
import { loadModule, loadCSS, loadJS } from "../../common/dom/load_resource";
|
||||
import { subscribeNotifications } from "../../data/ws-notifications";
|
||||
import debounce from "../../common/util/debounce";
|
||||
import { debounce } from "../../common/util/debounce";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { LovelaceConfig } from "../../data/lovelace";
|
||||
import { navigate } from "../../common/navigate";
|
||||
|
Loading…
x
Reference in New Issue
Block a user