Sending Reactive Values between Modules

Hi guys,

I've been trying to make a log-in page for my shiny app. At the same time, I want to develop the app as modular as possible, since it might get really big in the future.

I've created a module to contain the "Log In Page" and only that.
The Login UI has a couple of textInput() for the user to introduce username and password, and a "Log In" button. The logic of the server part of the module simply checks that username and password are correct and outputs a reactive value that includes 'username' and 'logged_status' (which could be FALSE or TRUE, depending on the success of the login). I've added a couple of nice outputs to inform the user on whether the login has been successful or not. So far so good.

The problem arises when I try to use this reactive value that includes the 'logged_status' to other modules.

The module would output something like this:


login_page_server <- function(input, output, session) {
  ns <- session$ns
  log_status <- reactive({
    
    #Trigger
    input$login_button
    
    
    isolate({
      user_username <- input$username
      user_password <- input$password
    })

    log_status <- check_login(username = user_username, password = user_password)
    ui_reaction_to_log_status(logged = log_status$logged)
  })

  reactive(log_status)
}

In the main server function, I'd call the output of this module's server as

app_server <- function(input, output,session) {
  
  log_status <- callModule(module = login_page_server, id = "login_page")
  callModule(module = subsequent_module, id = "subsequent_module", log_status= log_status)
}

Note that the result of the module 'login_page_server' should be used in the 'subsequent_module'.

sidebar_server <- function(input, output, session, log_status) {
  ns <- session$ns
observeEvent(log_status()[['logged']], {

if(log_status()[['logged']]{
 message("Log in successful")
}else{
 message("Log in failed")
}

})
   
}

With this set-up the 'subsequent_module' is not capable of receiving the 'logged' status and it doesn't react to pressing the button or anything.

What am I missing?

Thank you!

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.