Reputation: 83
Please help me to show spinner repeatedly when reactive value appear (when click action button)
library(shinycssloaders)
ui <- fluidPage(
titlePanel("Hello Shiny!"),
fluidRow(
column(width = 2, actionButton("actButton", "Click")),
column(width = 6, withSpinner(uiOutput("htmlExample")))
)
)
library(shiny)
library(shinycssloaders)
server<-function(input, output)
{
getRandomNumber <- function() {
Sys.sleep(1)
randamNumber <- runif(n = 1, min = 1e-12, max = .9999999999)
return(HTML(paste0("<h1>Hai Render Html ................",
randamNumber, "<h1>")))
}
observeEvent(input$actButton,{
if (input$actButton == 0)
return(0)
isolate({
output$htmlExample <- renderUI({
getRandomNumber()
})
})
})
}
Upvotes: 5
Views: 1372
Reputation: 7704
How about using busyIndicator
form the package shinysky
instead.
Here is an example code:
library(shinysky)
library(shiny)
ui <- fluidPage(
titlePanel("Hello Shiny!"),
fluidRow(
column(width = 2, actionButton("actButton", "Click")),
busyIndicator(text = 'Rendering HTML....'),
column(width = 6, uiOutput("htmlExample"))
)
)
server<-function(input, output)
{
getRandomNumber <- function() {
Sys.sleep(2)
randamNumber <- runif(n = 1, min = 1e-12, max = .9999999999)
return(HTML(paste0("<h1>Hi Render Html ................",
randamNumber, "<h1>")))
}
observeEvent(input$actButton,{
if (input$actButton == 0)
return(0)
isolate({
output$htmlExample <- renderUI({
getRandomNumber()
})
})
})
}
shinyApp(ui, server)
Hope it helps!
Upvotes: 0