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

Description Usage Note See Also Examples

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

1

Note

Due to an issue in shiny (see https://github.com/rstudio/shiny/issues/928), duplicated consecutive log messages will not get printed in R.

Log messages that cannot be serialized in JavaScript (such as many JavaScript Event objects that are cyclic) will not be printed in R.

See Also

logjs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
if (interactive()) {
  library(shiny)

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

eccel37/daatali documentation built on May 14, 2019, 8:42 a.m.