Skip to content

Instantly share code, notes, and snippets.

@dkulp2
Created October 26, 2018 18:30
Show Gist options
  • Save dkulp2/f1a773fcf29cfccd788bc7c8b7b35189 to your computer and use it in GitHub Desktop.
Save dkulp2/f1a773fcf29cfccd788bc7c8b7b35189 to your computer and use it in GitHub Desktop.
Slow shinyalert with large memory and callback
library(shiny)
library(shinyalert)
options(digits.secs=6)
ui <- fluidPage(
useShinyalert(),
actionButton("foo","Modal With Callback"),
actionButton("bar","Modal Without Callback"),
sliderInput("sz", "Matrix Dimension:", 10, 20000, 1000),
h3("Matrix size:"),
textOutput("matrix.sz"),
h3("Modal response time:"), textOutput("modal.time")
)
server <- function(input, output) {
modal.time <- reactiveVal()
ok <- function(x) message(x)
observeEvent(input$foo, {
t1 <- Sys.time()
shinyalert("With Callback", callbackR=ok)
modal.time(Sys.time()-t1)
})
observeEvent(input$bar, {
t1 <- Sys.time()
shinyalert("Without Callback")
modal.time(Sys.time()-t1)
})
output$matrix.sz <- renderPrint({ print(object.size(z()), units="auto") })
output$modal.time <- renderPrint({ modal.time() })
z <- reactive({
matrix(nrow=input$sz, ncol=input$sz)
})
}
# Run the application
shinyApp(ui = ui, server = server)
@dkulp2
Copy link
Author

dkulp2 commented Oct 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment