ayushsharma82 / ESP-DASH

Blazing fast library to create a functional dashboard for ESP8266 / ESP32
https://espdash.pro
GNU General Public License v3.0
976 stars 200 forks source link

2. Add ability to force refresh a particular card #180

Closed mathieucarbou closed 11 months ago

mathieucarbou commented 11 months ago

This PR adds the ability to only refresh a specific card.

This could be used in the case where the user click on a switch, but some application logic is preventing the switch to turn on. In this case, since there is no update of the component, the yellow waiting icon stays and blinks, as reported in issue #179.

So it is possible to force update only this specific component in the callback to avoid that.

A typical use case is:

buttonCard.attachCallback([&](int value) {
    if(application logic autorise the switch) {
      // do something
      dashboard.sendUpdates();
    }  else {
      // switch is prevented, but the component still needs to be refreshed to clear the waiting yellow icon
      dashboard.refreshCard(&buttonCard); 
    }
});