Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
xhr.addEventListener('error', function(e) {
// Flaky connections might fail fetching resources
if (attempts > 1) {
this._debounce = Debouncer.debounce(this._debounce,
timeOut.after(200),
this._getResource.bind(this, request, attempts - 1));
} else {
request.onError.call(this, e);
}
}.bind(this));
xhr.open('GET', request.url);
_checkRoute(route) {
// prevent list getting under toolbar
fireEvent(this, "iron-resize");
this._debouncer = Debouncer.debounce(
this._debouncer,
timeOut.after(0),
() => {
if (route.path === "") {
this.navigate(`${route.prefix}/picker`, true);
}
}
);
}
templateChanged(ev) {
this.template = ev.detail.value;
if (this.error) {
this.error = false;
}
this._debouncer = Debouncer.debounce(
this._debouncer,
timeOut.after(500),
() => {
this.renderTemplate();
}
);
}
stateObjChanged(newVal, oldVal) {
if (newVal) {
this.setProperties({
awayToggleChecked: newVal.attributes.away_mode === "on",
auxToggleChecked: newVal.attributes.aux_heat === "on",
onToggleChecked: newVal.state !== "off",
});
}
if (oldVal) {
this._debouncer = Debouncer.debounce(
this._debouncer,
timeOut.after(500),
() => {
this.fire("iron-resize");
}
);
}
}
stateObjChanged(newVal, oldVal) {
if (newVal) {
this.setProperties({
awayToggleChecked: newVal.attributes.away_mode === "on",
});
}
if (oldVal) {
this._debouncer = Debouncer.debounce(
this._debouncer,
timeOut.after(500),
() => {
this.fire("iron-resize");
}
);
}
}
filterChangedDebouncer(...args) {
this._debounceFilterChanged = Debouncer.debounce(
this._debounceFilterChanged,
timeOut.after(0),
() => {
this.filterChanged(...args);
}
);
}
_checkRoute(route) {
this._debouncer = Debouncer.debounce(
this._debouncer,
timeOut.after(0),
() => {
if (
!this.cloudStatus ||
(!this.cloudStatus.logged_in &&
!NOT_LOGGED_IN_URLS.includes(route.path))
) {
this.navigate("/config/cloud/login", true);
} else if (
this.cloudStatus.logged_in &&
!LOGGED_IN_URLS.includes(route.path)
) {
this.navigate("/config/cloud/account", true);
}
}
this._resizeListener = () => {
this._debouncer = Debouncer.debounce(
this._debouncer,
timeOut.after(10),
() => {
if (this._isAttached) {
this.resizeChart();
}
}
);
};