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

Busy indicator improvements #4172

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

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Dec 13, 2024

Closes #4169
Closes #4115

This PR makes the following improvements to useBusyIndicators():

  • Shows a spinner on recalculating htmlwidgets that have previously rendered an error (including req() and validate()).
  • Shows a spinner on tableOutput().
  • Places a minimum height on recalculating outputs so that the spinner is always visible.
Testing app
library(shiny)
library(reactable)
library(plotly)
library(visNetwork)

ui <- fluidPage(
  useBusyIndicators(),
  actionButton("run_tbl", "Run table"),
  actionButton("run_reactable", "Run reactable"),
  actionButton("run_text", "Run text"),
  actionButton("run_plotly", "Run plotly"),
  actionButton("run_network", "Run network"),
  textOutput("text"),
  fluidRow(
    column(6, tableOutput("tbl")),
    column(6, reactableOutput("r_tbl"))
  ),
  plotlyOutput("p"),
  visNetworkOutput("network")
)

server <- function(input, output, session) {
  output$text <- renderText({
    req(input$run_text)
    Sys.sleep(3)
    "test"
  })

  output$tbl <- renderTable({
    req(input$run_tbl)
    Sys.sleep(3)
    head(mtcars, 10)
  })

  output$r_tbl <- renderReactable({
    req(input$run_reactable)
    Sys.sleep(3)
    reactable(mtcars)
  })

  output$p <- renderPlotly({
    # validate(need(input$run_plotly %% 2, "Please run plotly"))
    req(input$run_plotly)
    Sys.sleep(3)
    plotly::plot_ly()
  })

  output$network <- renderVisNetwork({
    # validate(need(input$run_network %% 2, "Please run network"))
    req(input$run_network)
    Sys.sleep(30)
    nodes <- data.frame(id = 1:3)
    edges <- data.frame(from = c(1, 2), to = c(1, 3))

    visNetwork(nodes, edges)
  })
}

shinyApp(ui, server)

@cpsievert cpsievert marked this pull request as ready for review December 13, 2024 17:19
@cpsievert cpsievert force-pushed the busy-indicator-improvements branch from cfbd253 to 75832be Compare December 13, 2024 17:27
@cpsievert cpsievert requested a review from gadenbuie December 16, 2024 15:25
Copy link
Member

@gadenbuie gadenbuie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants