R/browser_button.R

Defines functions browser_button

Documented in browser_button

#' Insert an hidden browser button
#'
#' See \url{https://rtask.thinkr.fr/a-little-trick-for-debugging-shiny/} for more context.
#'
#' @return Used for side effects.
#'     Prints the code to the console.
#' @export
#'
#' @importFrom cli cat_rule cat_line
browser_button <- function() {
  cat_rule("To be copied in your UI")
  cat_line(darkgrey('actionButton("browser", "browser"),'))
  cat_line(darkgrey('tags$script("$(\'#browser\').hide();")'))
  cat_line()
  cat_rule("To be copied in your server")
  cat_line(darkgrey("observeEvent(input$browser,{"))
  cat_line(darkgrey("  browser()"))
  cat_line(darkgrey("})"))
  cat_line()
  cat_line("By default, this button will be hidden.")
  cat_line("To show it, open your web browser JavaScript console")
  cat_line("And run $('#browser').show();")
}

Try the golem package in your browser

Any scripts or data that you put into this service are public.

golem documentation built on Oct. 18, 2022, 5:09 p.m.