Search code examples
rshinyshiny-servershinyappsshinyjs

Immediately seeing changes in R shiny UI, in the browser, after making changes in code without having to restart the server?


Is it possible to see the changes in UI (only the UI and not server) after I make changes in my code, without having to restart the server/refresh the page? If cache needs to be cleared, can that also be done?


Solution

  • You could use reactiveFileReader to regularly source the code you'd save in another file, and renderUI()/uiOutput to display that dynamic UI:

    app.R

    library(shiny)
    
    ui <- uiOutput("ui")
    
    server <- function(input, output, session) {
      ui <- reactiveFileReader(1000, session, "source.R", source)
      output$ui <- renderUI(ui())
    }
    
    shinyApp(ui = ui, server = server)
    

    source.R

    fluidPage(
      textInput("text", "text"),
      textInput("text2", "text")
      )
    

    You still have to find out howto get rid of that "TRUE": result