Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Busy indicator improvements#4172

Merged
cpsievert merged 7 commits intomainfrom
busy-indicator-improvements
Jan 22, 2025
Merged

Busy indicator improvements#4172
cpsievert merged 7 commits intomainfrom
busy-indicator-improvements

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!

@cpsievert cpsievert merged commit d764ea9 into main Jan 22, 2025
12 checks passed
@cpsievert cpsievert deleted the busy-indicator-improvements branch January 22, 2025 20:14
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