Dashboard with multiple tabs (shiny.router), all tabs load on start #116
-
In a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @shahreyar-abeer, It's hard to tell what exactly causes your app to slow down without an example, but I've created a simple app that I think illustrates the issue. Let me know if this is what you're struggling with. library(shiny)
library(shiny.fluent)
library(shiny.router)
router <- make_router(
route(
"/",
tagList(
Label("Home page")
)
),
route(
"hidden",
tagList(
Label("Hidden page"),
textOutput("text")
),
server = function(input, output, session) {
output$text <- renderText({
Sys.sleep(5)
"Delayed text"
})
}
)
)
ui <- fluentPage(router$ui)
server <- function(input, output, session) {
router$server(input, output, session)
}
shinyApp(ui, server) this app takes 5 seconds to open due to a library(shiny)
library(shiny.fluent)
library(shiny.router)
router <- make_router(
route(
"/",
tagList(
Label("Home page")
)
),
route(
"hidden",
tagList(
Label("Hidden page"),
textOutput("text")
),
server = function(input, output, session) {
opened <- reactiveVal(FALSE)
observe({
# Set `opened` reactive to indicate whether this page has been opened
# It runs only once, after page has been opened for the first time
if (!opened()) {
opened(shiny.router::get_page() == "hidden")
}
})
output$text <- renderText({
shiny::req(opened())
Sys.sleep(5)
"Delayed text"
})
}
)
)
ui <- fluentPage(router$ui)
server <- function(input, output, session) {
router$server(input, output, session)
}
shinyApp(ui, server) The app opens instantly. When we go to Does this help you speed up your app? |
Beta Was this translation helpful? Give feedback.
Hi @shahreyar-abeer,
It's hard to tell what exactly causes your app to slow down without an example, but I've created a simple app that I think illustrates the issue. Let me know if this is what you're struggling with.