Is there a way to turn on (or are there plans to add) code completion for shiny input and output elements? I find that 90% of my bug troubleshooting in shiny is because I do something stupid like this:
# server code
output$box <- renderUI({
checkboxInput("check", "a checkbox")
})
variable <- reactive({
req(input$checkbox)
some_code()
})
Since R generally uses lazy evaluation for shiny elements, my reactive variable never gets calculated (or my conditional UI doesn't show up, or whatever), because it's waiting for an input variable that doesn't exist. The lazy evaluation is usually nice, but is a pain in the butt for debugging ("why isnt my stupid ___ showing up?!"). Rstudio's autocomplete doesn't give me anything after input$
and its line-by-line error checking doesn't say "no variable with that name in scope" or whatever. Similarly, output$
variables don't recognize when there's no xxOutput()
object that calls them, and don't recognize when xxOutput()
calls an undefined output$
object. I understand that this kind of code completion may be trickier in split ui/server apps, but I feel like it would save hours of frustration and headache.
Thanks!