1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/withProgressShiny.R
\name{withProgressShiny}
\alias{withProgressShiny}
\title{Use Progressr in Shiny Apps: Plug-in Backward-Compatible Replacement for shiny::withProgress()}
\usage{
withProgressShiny(
expr,
...,
message = NULL,
detail = NULL,
inputs = list(message = NULL, detail = "message"),
env = parent.frame(),
quoted = FALSE,
handlers = c(shiny = handler_shiny, progressr::handlers(default = NULL))
)
}
\arguments{
\item{expr, \ldots, env, quoted}{Arguments passed to \code{\link[shiny:withProgress]{shiny::withProgress()}} as is.}
\item{message, detail}{(character string) The message and the detail message to be passed to \code{\link[shiny:withProgress]{shiny::withProgress()}}.}
\item{inputs}{(named list) Specifies from what sources the Shiny progress
elements 'message' and 'detail' should be updated. Valid sources are
\code{"message"}, \code{"sticky_message"} and \code{"non_sticky_message"}, where
\code{"message"} is short for \code{c("non_sticky_message", "sticky_message")}. For
example, \code{inputs = list(message = "sticky_message", detail = "message")}
will update the Shiny 'message' component from sticky messages only,
whereas the 'detail' component is updated using any message.}
\item{handlers}{Zero or more progression handlers used to report on progress.}
}
\value{
The value of \link[shiny:withProgress]{shiny::withProgress}.
}
\description{
A plug-in, backward-compatible replacement for \code{\link[shiny:withProgress]{shiny::withProgress()}}.
}
\section{Requirements}{
This function requires the \pkg{shiny} package and will use the
\code{\link[=handler_shiny]{handler_shiny()}} \strong{progressr} handler internally to report on updates.
}
\examples{
library(shiny)
library(progressr)
app <- shinyApp(
ui = fluidPage(
plotOutput("plot")
),
server = function(input, output) {
output$plot <- renderPlot({
X <- 1:15
withProgressShiny(message = "Calculation in progress",
detail = "Starting ...",
value = 0, {
p <- progressor(along = X)
y <- lapply(X, FUN=function(x) {
Sys.sleep(0.25)
p(sprintf("x=\%d", x))
})
})
plot(cars)
## Terminate the Shiny app
Sys.sleep(1.0)
stopApp(returnValue = invisible())
})
}
)
local({
oopts <- options(device.ask.default = FALSE)
on.exit(options(oopts))
if (interactive()) print(app)
})
}
|