artem-sedykh / mini-humidifier

Minimalistic humidifier card for Home Assistant Lovelace UI
MIT License
155 stars 26 forks source link

Wait for loading dependencies. #91

Closed Anonym-tsk closed 2 years ago

Anonym-tsk commented 2 years ago

Fixes #89

regevbr commented 2 years ago

thanks I will review and test soon

regevbr commented 2 years ago

let's try to come up with a more generic and efficient solution and apply it to all the code, not just the main file. Your current causes a lot of ops during each render, where we can save the "loaded" state once it occurs and then only look at it.

Anonym-tsk commented 2 years ago

Please read this article and look at this gist.

  1. It's impossible to use async loader with ScopedRegistryHost
  2. It works without whenDefined check
regevbr commented 2 years ago

What you did is not a solution and it only works now by chance since those entities which we currently use are already loaded and this can change in the future ... What i did already took under account the links you mentioned as you can see i add them to the registry in an async matter. Your first commit was in yhe right direction please revisit it and the comment i left for it. You can introduce an enhancement where you check if a given element is already defined in a sync matter and use it instead if the whenDefined matter.

Anonym-tsk commented 2 years ago

So, you know the problem and you understand the bug with asynchronous loading resources for now. Please do your best and fix it.

I think that ScopedRegistryHost is not needed here, but you can do something else.