Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thisisnic/7c849cd34ab6a485bef8e36a643229f7 to your computer and use it in GitHub Desktop.
Save thisisnic/7c849cd34ab6a485bef8e36a643229f7 to your computer and use it in GitHub Desktop.
Shiny app with expensive operation - still pauses with datatableproxy
library(shiny)
library(DT)
library(dplyr)
ui <- fluidPage(
DTOutput("myTable")
)
server <- function(input, output, session){
loopData <- reactive({
invalidateLater(1000, session)
get_data()
})
output$myTable = DT::renderDataTable({
isolate(loopData())
})
proxy <- dataTableProxy('myTable', deferUntilFlush = TRUE)
observe({
replaceData(proxy, loopData(), resetPaging = FALSE, clearSelection = FALSE)
})
}
get_data <- function(){
expensive_operation()
tibble(Value = rnorm(20))
}
expensive_operation <- function(){
invisible(rnorm(10000000))
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment