Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Before update callback #213

Merged

Conversation

mathieucarbou
Copy link
Contributor

Introducing a callback to let the application aware when a refresh is requested, and if it is partial or not.

This helps improving performance by only refreshing some cards when the user reloads a page and not in a regular loop.

Example:

  dashboard.onBeforeUpdate([](bool changes_only) {
    if (!changes_only) {
      logger.debug(TAG, "Dashboard refresh requested");
      YaSolR::Website.initCards();
    }
  });

Then, we don't need to "prepare" any card before, but only when requested.

I.e. initCards() contain some card.update() calls for some application config, app info, etc. Basically values that are either never refreshed (app scope), or infrequently refreshed (i.e. a config could be updated through mqtt behind), so only refreshing them when the user refreshed the web page is acceptable.

@mathieucarbou
Copy link
Contributor Author

Note: this PR contains #210 in a commit (I have #210 in my main branch to trigger CI)

@mathieucarbou mathieucarbou force-pushed the BeforeUpdateCallback branch from dae22d4 to 1c8e94b Compare May 30, 2024 20:33
@ayushsharma82 ayushsharma82 changed the base branch from master to dev June 2, 2024 19:06
@ayushsharma82 ayushsharma82 merged commit 6f05017 into ayushsharma82:dev Jun 2, 2024
10 checks passed
@mathieucarbou mathieucarbou deleted the BeforeUpdateCallback branch June 5, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants