shinyjs (version 1.0)

showLog: Print any JavaScript console.log messages in the R console

Description

When developing and debugging a Shiny that uses custom JavaScript code, it can be helpful to use console.log() messages in JavaScript. This function allows you to see these messages printed in the R console directly rather than having to open the JavaScript console in the browser to view the messages. This function must be called in a Shiny app's server function, and you also need to pass the showLog=TRUE parameter to useShinyjs().

Usage

showLog()

Arguments

See Also

logjs

Examples

Run this code
# NOT RUN {
if (interactive()) {
  library(shiny)

  shinyApp(
    ui = fluidPage(
      useShinyjs(),
      textInput("text", "Type something")
    ),
    server = function(input, output) {
      showLog()
      logjs("App started")
      observe({
        logjs(paste("Length of text:", nchar(input$text)))
      })
    }
  )
}
# }

Run the code above in your browser using DataLab