mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-01 13:37:47 +00:00
name change + comment
This commit is contained in:
parent
2df3041b49
commit
59b5b0f9dd
@ -13,7 +13,8 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
|
|||||||
class SubscribeClass extends superClass {
|
class SubscribeClass extends superClass {
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
|
|
||||||
protected hassSubscribeNeedsProperties?: string[];
|
// we wait with subscribing till these properties are set on the host element
|
||||||
|
protected hassSubscribeRequiredHostProps?: string[];
|
||||||
|
|
||||||
private __unsubs?: Array<UnsubscribeFunc | Promise<UnsubscribeFunc>>;
|
private __unsubs?: Array<UnsubscribeFunc | Promise<UnsubscribeFunc>>;
|
||||||
|
|
||||||
@ -43,11 +44,11 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
|
|||||||
this.__checkSubscribed();
|
this.__checkSubscribed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.hassSubscribeNeedsProperties) {
|
if (!this.hassSubscribeRequiredHostProps) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const key of changedProps.keys()) {
|
for (const key of changedProps.keys()) {
|
||||||
if (this.hassSubscribeNeedsProperties.includes(key as string)) {
|
if (this.hassSubscribeRequiredHostProps.includes(key as string)) {
|
||||||
this.__checkSubscribed();
|
this.__checkSubscribed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -65,7 +66,7 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
|
|||||||
this.__unsubs !== undefined ||
|
this.__unsubs !== undefined ||
|
||||||
!(this as unknown as Element).isConnected ||
|
!(this as unknown as Element).isConnected ||
|
||||||
this.hass === undefined ||
|
this.hass === undefined ||
|
||||||
this.hassSubscribeNeedsProperties?.some(
|
this.hassSubscribeRequiredHostProps?.some(
|
||||||
(prop) => this[prop] === undefined
|
(prop) => this[prop] === undefined
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
@ -32,7 +32,7 @@ class HuiEnergyCarbonGaugeCard
|
|||||||
|
|
||||||
@state() private _data?: EnergyData;
|
@state() private _data?: EnergyData;
|
||||||
|
|
||||||
protected hassSubscribeNeedsProperties = ["_config"];
|
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||||
|
|
||||||
public getCardSize(): number {
|
public getCardSize(): number {
|
||||||
return 4;
|
return 4;
|
||||||
|
@ -49,7 +49,7 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
|
|
||||||
@query("ha-chart-base") private _chart?: HaChartBase;
|
@query("ha-chart-base") private _chart?: HaChartBase;
|
||||||
|
|
||||||
protected hassSubscribeNeedsProperties = ["_config"];
|
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||||
|
|
||||||
public hassSubscribe(): UnsubscribeFunc[] {
|
public hassSubscribe(): UnsubscribeFunc[] {
|
||||||
return [
|
return [
|
||||||
|
@ -43,7 +43,7 @@ class HuiEnergyDistrubutionCard
|
|||||||
|
|
||||||
@state() private _data?: EnergyData;
|
@state() private _data?: EnergyData;
|
||||||
|
|
||||||
protected hassSubscribeNeedsProperties = ["_config"];
|
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||||
|
|
||||||
public setConfig(config: EnergyDistributionCardConfig): void {
|
public setConfig(config: EnergyDistributionCardConfig): void {
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
@ -62,7 +62,7 @@ export class HuiEnergyGasGraphCard
|
|||||||
|
|
||||||
@state() private _unit?: string;
|
@state() private _unit?: string;
|
||||||
|
|
||||||
protected hassSubscribeNeedsProperties = ["_config"];
|
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||||
|
|
||||||
public hassSubscribe(): UnsubscribeFunc[] {
|
public hassSubscribe(): UnsubscribeFunc[] {
|
||||||
return [
|
return [
|
||||||
|
@ -35,7 +35,7 @@ class HuiEnergyGridGaugeCard
|
|||||||
|
|
||||||
@state() private _data?: EnergyData;
|
@state() private _data?: EnergyData;
|
||||||
|
|
||||||
protected hassSubscribeNeedsProperties = ["_config"];
|
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||||
|
|
||||||
public hassSubscribe(): UnsubscribeFunc[] {
|
public hassSubscribe(): UnsubscribeFunc[] {
|
||||||
return [
|
return [
|
||||||
|
@ -30,7 +30,7 @@ class HuiEnergySolarGaugeCard
|
|||||||
|
|
||||||
@state() private _data?: EnergyData;
|
@state() private _data?: EnergyData;
|
||||||
|
|
||||||
protected hassSubscribeNeedsProperties = ["_config"];
|
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||||
|
|
||||||
public hassSubscribe(): UnsubscribeFunc[] {
|
public hassSubscribe(): UnsubscribeFunc[] {
|
||||||
return [
|
return [
|
||||||
|
@ -61,7 +61,7 @@ export class HuiEnergySolarGraphCard
|
|||||||
|
|
||||||
@state() private _end = endOfToday();
|
@state() private _end = endOfToday();
|
||||||
|
|
||||||
protected hassSubscribeNeedsProperties = ["_config"];
|
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||||
|
|
||||||
public hassSubscribe(): UnsubscribeFunc[] {
|
public hassSubscribe(): UnsubscribeFunc[] {
|
||||||
return [
|
return [
|
||||||
|
@ -45,7 +45,7 @@ export class HuiEnergySourcesTableCard
|
|||||||
|
|
||||||
@state() private _data?: EnergyData;
|
@state() private _data?: EnergyData;
|
||||||
|
|
||||||
protected hassSubscribeNeedsProperties = ["_config"];
|
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||||
|
|
||||||
public hassSubscribe(): UnsubscribeFunc[] {
|
public hassSubscribe(): UnsubscribeFunc[] {
|
||||||
return [
|
return [
|
||||||
|
@ -50,7 +50,7 @@ export class HuiEnergyUsageGraphCard
|
|||||||
|
|
||||||
@state() private _end = endOfToday();
|
@state() private _end = endOfToday();
|
||||||
|
|
||||||
protected hassSubscribeNeedsProperties = ["_config"];
|
protected hassSubscribeRequiredHostProps = ["_config"];
|
||||||
|
|
||||||
public hassSubscribe(): UnsubscribeFunc[] {
|
public hassSubscribe(): UnsubscribeFunc[] {
|
||||||
return [
|
return [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user