name change + comment

This commit is contained in:
Bram Kragten 2022-02-28 18:47:38 +01:00
parent 2df3041b49
commit 59b5b0f9dd
No known key found for this signature in database
GPG Key ID: FBE2DFDB363EF55B
10 changed files with 14 additions and 13 deletions

View File

@ -13,7 +13,8 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
class SubscribeClass extends superClass {
@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>>;
@ -43,11 +44,11 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
this.__checkSubscribed();
return;
}
if (!this.hassSubscribeNeedsProperties) {
if (!this.hassSubscribeRequiredHostProps) {
return;
}
for (const key of changedProps.keys()) {
if (this.hassSubscribeNeedsProperties.includes(key as string)) {
if (this.hassSubscribeRequiredHostProps.includes(key as string)) {
this.__checkSubscribed();
return;
}
@ -65,7 +66,7 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
this.__unsubs !== undefined ||
!(this as unknown as Element).isConnected ||
this.hass === undefined ||
this.hassSubscribeNeedsProperties?.some(
this.hassSubscribeRequiredHostProps?.some(
(prop) => this[prop] === undefined
)
) {

View File

@ -32,7 +32,7 @@ class HuiEnergyCarbonGaugeCard
@state() private _data?: EnergyData;
protected hassSubscribeNeedsProperties = ["_config"];
protected hassSubscribeRequiredHostProps = ["_config"];
public getCardSize(): number {
return 4;

View File

@ -49,7 +49,7 @@ export class HuiEnergyDevicesGraphCard
@query("ha-chart-base") private _chart?: HaChartBase;
protected hassSubscribeNeedsProperties = ["_config"];
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [

View File

@ -43,7 +43,7 @@ class HuiEnergyDistrubutionCard
@state() private _data?: EnergyData;
protected hassSubscribeNeedsProperties = ["_config"];
protected hassSubscribeRequiredHostProps = ["_config"];
public setConfig(config: EnergyDistributionCardConfig): void {
this._config = config;

View File

@ -62,7 +62,7 @@ export class HuiEnergyGasGraphCard
@state() private _unit?: string;
protected hassSubscribeNeedsProperties = ["_config"];
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [

View File

@ -35,7 +35,7 @@ class HuiEnergyGridGaugeCard
@state() private _data?: EnergyData;
protected hassSubscribeNeedsProperties = ["_config"];
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [

View File

@ -30,7 +30,7 @@ class HuiEnergySolarGaugeCard
@state() private _data?: EnergyData;
protected hassSubscribeNeedsProperties = ["_config"];
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [

View File

@ -61,7 +61,7 @@ export class HuiEnergySolarGraphCard
@state() private _end = endOfToday();
protected hassSubscribeNeedsProperties = ["_config"];
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [

View File

@ -45,7 +45,7 @@ export class HuiEnergySourcesTableCard
@state() private _data?: EnergyData;
protected hassSubscribeNeedsProperties = ["_config"];
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [

View File

@ -50,7 +50,7 @@ export class HuiEnergyUsageGraphCard
@state() private _end = endOfToday();
protected hassSubscribeNeedsProperties = ["_config"];
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [