I'm trying to learn the rhino modules to develop R shiny apps but got stuck with this simple app:
app/view/page1.R
box::use(
shiny[moduleServer, textOutput, renderText, NS, div],
shiny.fluent[TextField.shinyInput, Stack]
)
#' @export
ui <- function(id){
ns <- NS(id)
Stack(TextField.shinyInput(ns("page1input"), value = "default value"),
textOutput(ns('page1print'))
)
}
#' @export
server <- function(id) {
moduleServer(id, function(input, output, session){
output$page1print <- renderText(sprintf("Input from above: %s", input$page1input))
})
}
main.R
box::use(
shiny[div, moduleServer, NS, renderUI, tags, uiOutput, renderText],
shiny.fluent[fluentPage]
)
box::use(
app/view/page1
)
#' @export
ui <- function(id) {
ns <- NS(id)
fluentPage(
page1$ui('p1')
)
}
#' @export
server <- function(id) {
moduleServer(id, function(input, output, session) {
page1$server('p1')
})
}
I expect the app to print the user's input but it doesn't. Could anyone help? Thanks a lot
You forgot to add namespacing to your call to
page1$ui
Now
main$server
is able to read inputs frompage1$ui
. Don't worry, everyone makes this mistake several times ;).