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

Stream box values with updateBoxValue #304

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

colearendt
Copy link

Adds a updateBoxValue function to stream box values directly to the infoBox and valueBox values without re-rendering the rest of the HTML. Useful for values that change often.

Also adds id values for the infoBox and valueBox items (NULL by default).

@gadenbuie
Copy link
Member

Hi @colearendt -- first thanks for opening this PR, I really like the additional functionality of being able to update the box values without re-rendering the whole box.

I made some changes to the API that you might be interested in merging (or using), which you can see in gadenbuie/shinyDashboard@stream-box.

Notably, I changed the syntax around updateBoxValue() to update a single box, identified by inputId. Currently this function takes only value in addition to session.

updateBoxValue(session, inputId = "singlebox", value = value())

The motivation for this change would be to make it easier to add functionality to update other properties of the box, such as the color or icon, e.g.

# not yet implemented
updateBoxValue(session, inputId = "singlebox", value = value(), status = "warning")

I kept the ability to update multiple boxes at once in a function called updateBoxValues() that works exactly as your updateBoxValue() did. I also used this opportunity to refactor a bit and remove the rlang dependency.

Finally, I added a small CSS animation on the box value update that adds a small flash to the value update.

Feel free to use, lose, or modify any part of the code I've written. Where I think it may contribute to this PR is:

  1. Make room for adding updating of additional properties, such as color or icon.

  2. We could possibly simplify the javascript message handler to process updates to individual boxes (not needing to loop over data) and instead handle looping in R in updateBoxValues().

  3. A more consistent API that matches the formals of other shinyDashboard functions.

@markusdumke
Copy link

Any news on this PR? I think it would be a great feature vastly improving user experience and performance.

@exproject
Copy link

I'd also like to follow bump this. This function shows up in one of the shiny demos (the twitter conference demo) but it's not a part of any of the code bases making it a little confusing when trying to sort out update value boxes.

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.

4 participants