-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
showLog()
function to print javascript log messages in R console;
fixes #88
- Loading branch information
Showing
12 changed files
with
157 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: shinyjs | ||
Title: Easily Improve the User Experience of Your Shiny Apps in Seconds | ||
Version: 0.7.9004 | ||
Version: 0.7.9005 | ||
Authors@R: person("Dean", "Attali", email = "[email protected]", | ||
role = c("aut", "cre")) | ||
Description: Perform common useful JavaScript operations in Shiny apps that will | ||
|
@@ -16,6 +16,7 @@ Depends: | |
Imports: | ||
digest (>= 0.6.8), | ||
htmltools (>= 0.2.6), | ||
jsonlite, | ||
miniUI (>= 0.1.1), | ||
shiny (>= 0.11.1), | ||
stats | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#' Print any JavaScript console.log messages in the R console | ||
#' | ||
#' When developing and debugging a Shiny that uses custom JavaScript code, | ||
#' it can be helpful to use \code{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.\cr\cr | ||
#' This function must be called in a Shiny app's server function, and you also | ||
#' need to pass the \code{showLog=TRUE} parameter to \code{useShinyjs()}. | ||
#' @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. | ||
#' @examples | ||
#' if (interactive()) { | ||
#' library(shiny) | ||
#' | ||
#' shinyApp( | ||
#' ui = fluidPage( | ||
#' useShinyjs(showLog = TRUE), # Set up shinyjs with showLog | ||
#' textInput("text", "Type something") | ||
#' ), | ||
#' server = function(input, output) { | ||
#' showLog() | ||
#' observe({ | ||
#' logjs(paste("Length of text:", nchar(input$text))) | ||
#' }) | ||
#' } | ||
#' ) | ||
#' } | ||
#' @seealso \code{\link[shinyjs]{logjs}} | ||
#' @export | ||
showLog <- function() { | ||
session <- getSession() | ||
shiny::observeEvent(session$input[['shinyjs-showLog']], { | ||
message("JAVASCRIPT LOG: ", | ||
jsonlite::toJSON(session$input[['shinyjs-showLog']], | ||
auto_unbox = TRUE) | ||
) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters