Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable $isActive() in modules, v2 #85

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Enable $isActive() in modules, v2 #85

wants to merge 2 commits into from

Conversation

etiennebacher
Copy link
Owner

Another way to enable this. I don't know if this less hacky than #84, but it requires more actions from the user, namely:

  • passing an id wrapped in ns() in $new()
  • passing session = session in $isActive() and similar methods.

Example:

library(shiny)
library(conductor)

######### start of module
mod_num_ui <- function(id){
  ns <- NS(id)
  tagList(
    numericInput(inputId = ns("num"),  label = "Enter a number", value = 5, min = 0, max = 10),   
    actionButton(  inputId = ns("tour"), label = "start Tour")  
  )
}

mod_num_server <- function(input, output, session) {
  ns <- session$ns

  guide <- Conductor$new(id = ns("myguide"))$
    step(
      el = ns("num"),  
      title = "Step 1",
      text = "This is a numericInput."
    )
  
  guide$init(session = session)

  observeEvent(
    guide$isActive(session = session),
    {
      print(guide$isActive(session = session))
    }
  )
  
  observeEvent(
    input$tour,
    {
      guide$start(session = session)
    }
  )
}

########## end of module

ui <- fluidPage(
  useConductor(),
  mod_num_ui("mod1")
)

server <- function(input, output, session){
  callModule(mod_num_server, "mod1")
}

shinyApp(ui = ui, server = server)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant