Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Shiny apps inside functions so that they are created a runtime #2

Open
gadenbuie opened this issue Mar 25, 2024 · 0 comments
Open

Comments

@gadenbuie
Copy link

gadenbuie commented Mar 25, 2024

There appear to be several Shiny apps in this package that are built in this way

may.app=shinyApp(
# This creates the User Interface (UI)
# This creates the User Interface (UI)
ui = pageWithSidebar(

The problem with this approach is that the may.app object is created when the package is built (or installed) rather than when the user actually calls may.app. This can lead to subtle bugs when your package is installed or built with an older version of shiny and then the user later updates their version of shiny.

It's also problematic because warnings emitted by any of the shiny functions you've used become installation errors. We are in the process of deprecating shiny::dataTableOutput() in favor of functions provided by the DT package, and we will soon be emitting a warning when dataTableOutput() is called to inform users of this change. Because may.app is created at buildtime rather than runtime, the warning shows up when the package is installed, rather than when the user starts the app.

To fix this, please convert may.app and other app objects into functions:

may.app <- function() {
  shinyApp(
    ui = pageWithSidebar(
      # ...
    ),
    server = function(input, output, session) {
      # ...
    }
  )
}

We are working on releasing shiny 1.8.1 now that informs users of the deprecation using message(). We plant to start to emit warnings in the following version of shiny.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant