conductor
conductor copied to clipboard
Enhancement (?)
I can create and run guides at a module level. By this I mean I can define and init/start conductor guides within a module (provided I am careful to namespace the ids. This works great since I can manage the module and the guide together. This is excellent news!
However, the reactivity associated with the guide does not work in this mode. For example. the guide$isActive() always returns NULL because the underlying session input does not exist (not by the expected name or any other names). See REPREX. I gather that the guide(s) must be initialised in the "main" server for the input values to be created and work correctly to give the necessary reactivity. I am not sure why this is. This limitation is not discussed in the documentation.
My questions are these: Is this behaviour by design or an oversight? Is it simple to enable the session$inputs to be created from within modules?
Below is some code I borrowed from the documentation with the initialisation and start functions triggered within the module.
library(shiny)
library(conductor)
guide <- Conductor$new()$
step(
title = "hello there"
)
# First module
mod_num_ui <- function(id){
ns <- NS(id)
numericInput(ns("num"), label = "Enter a number", value = 5, min = 0, max = 10)
}
mod_num_server <- function(input, output, session){
ns <- session$ns
guide$
step(
el = ns("num"), # use namespace
title = "Step 1",
text = "This is a numericInput."
)
observeEvent(
guide$isActive(),
{
print(guide$isActive()) ### This never gets printed
}
)
# launch after module called
guide$init()$start()
}
# Second module
mod_text_ui <- function(id){
ns <- NS(id)
textInput(ns("text"), label = "Type some text")
}
mod_text_server <- function(input, output, session){
ns <- session$ns
guide$
step(
el = ns("text"),
title = "Step 2",
text = "This is a textInput."
)
}
# Main app
ui <- fluidPage(
useConductor(),
mod_num_ui("num1"),
mod_text_ui("text1")
)
server <- function(input, output, session){
callModule(mod_num_server, "num1")
callModule(mod_text_server, "text1")
print(input) ### there are no guide related input entries
}
shinyApp(ui = ui, server = server)