bs4Dash using moduleServer()

92 Views Asked by At

I have an issue with using modules with bs4Dash. I have created a ShinyApp with modules using golem which I created from my previous ShinyApp. I have no issue in using input$dark_mode == TRUE or if (input$dark_mode) if it is a single app, for example,

if (input$dark_mode)
{ 
p1 <- plotly::ggplotly(plot01 + ggplot_dark_theme)  
p1
}
else { 
p1 <- plotly::ggplotly(plot01 + ggplot_light_theme) 
p1
}

But when you use module it returns Error: argument is of length zero

Has anyone seen error like this? Is there a fix? Thanks.

1

There are 1 best solutions below

0
On

Update:

I have fixed this by using reactiveValues()and observe() functions in app_server.R

# Global
  global <- reactiveValues()
  observe({global$dark_mode <-  input$dark_mode})

And linking global to the plot modules.