Debian Codegraph @

man/Progress.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/progress.R
3 \name{Progress}
4 \alias{Progress}
5 \title{Reporting progress (object-oriented API)}
6 \description{
7 Reporting progress (object-oriented API)
8
9 Reporting progress (object-oriented API)
10 }
11 \details{
12 Reports progress to the user during long-running operations.
13
14 This package exposes two distinct programming APIs for working with
15 progress. \code{\link[=withProgress]{withProgress()}} and \code{\link[=setProgress]{setProgress()}}
16 together provide a simple function-based interface, while the
17 \code{Progress} reference class provides an object-oriented API.
18
19 Instantiating a \code{Progress} object causes a progress panel to be
20 created, and it will be displayed the first time the \code{set}
21 method is called. Calling \code{close} will cause the progress panel
22 to be removed.
23
24 As of version 0.14, the progress indicators use Shiny's new notification API.
25 If you want to use the old styling (for example, you may have used customized
26 CSS), you can use \code{style="old"} each time you call
27 \code{Progress$new()}. If you don't want to set the style each time
28 \code{Progress$new} is called, you can instead call
29 \code{\link[=shinyOptions]{shinyOptions(progress.style="old")}} just once, inside the server
30 function.
31 }
32 \examples{
33 ## Only run examples in interactive R sessions
34 if (interactive()) {
35
36 ui <- fluidPage(
37 plotOutput("plot")
38 )
39
40 server <- function(input, output, session) {
41 output$plot <- renderPlot({
42 progress <- Progress$new(session, min=1, max=15)
43 on.exit(progress$close())
44
45 progress$set(message = 'Calculation in progress',
46 detail = 'This may take a while...')
47
48 for (i in 1:15) {
49 progress$set(value = i)
50 Sys.sleep(0.5)
51 }
52 plot(cars)
53 })
54 }
55
56 shinyApp(ui, server)
57 }
58 }
59 \seealso{
60 \code{\link[=withProgress]{withProgress()}}
61 }
62 \section{Methods}{
63 \subsection{Public methods}{
64 \itemize{
65 \item \href{#method-Progress-new}{\code{Progress$new()}}
66 \item \href{#method-Progress-set}{\code{Progress$set()}}
67 \item \href{#method-Progress-inc}{\code{Progress$inc()}}
68 \item \href{#method-Progress-getMin}{\code{Progress$getMin()}}
69 \item \href{#method-Progress-getMax}{\code{Progress$getMax()}}
70 \item \href{#method-Progress-getValue}{\code{Progress$getValue()}}
71 \item \href{#method-Progress-close}{\code{Progress$close()}}
72 \item \href{#method-Progress-clone}{\code{Progress$clone()}}
73 }
74 }
75 \if{html}{\out{<hr>}}
76 \if{html}{\out{<a id="method-Progress-new"></a>}}
77 \if{latex}{\out{\hypertarget{method-Progress-new}{}}}
78 \subsection{Method \code{new()}}{
79 Creates a new progress panel (but does not display it).
80 \subsection{Usage}{
81 \if{html}{\out{<div class="r">}}\preformatted{Progress$new(
82 session = getDefaultReactiveDomain(),
83 min = 0,
84 max = 1,
85 style = getShinyOption("progress.style", default = "notification")
86 )}\if{html}{\out{</div>}}
87 }
88
89 \subsection{Arguments}{
90 \if{html}{\out{<div class="arguments">}}
91 \describe{
92 \item{\code{session}}{The Shiny session object, as provided by \code{shinyServer} to
93 the server function.}
94
95 \item{\code{min}}{The value that represents the starting point of the progress
96 bar. Must be less than \code{max}.}
97
98 \item{\code{max}}{The value that represents the end of the progress bar. Must be
99 greater than \code{min}.}
100
101 \item{\code{style}}{Progress display style. If \code{"notification"} (the default),
102 the progress indicator will show using Shiny's notification API. If
103 \code{"old"}, use the same HTML and CSS used in Shiny 0.13.2 and below (this
104 is for backward-compatibility).}
105 }
106 \if{html}{\out{</div>}}
107 }
108 }
109 \if{html}{\out{<hr>}}
110 \if{html}{\out{<a id="method-Progress-set"></a>}}
111 \if{latex}{\out{\hypertarget{method-Progress-set}{}}}
112 \subsection{Method \code{set()}}{
113 Updates the progress panel. When called the first time, the
114 progress panel is displayed.
115 \subsection{Usage}{
116 \if{html}{\out{<div class="r">}}\preformatted{Progress$set(value = NULL, message = NULL, detail = NULL)}\if{html}{\out{</div>}}
117 }
118
119 \subsection{Arguments}{
120 \if{html}{\out{<div class="arguments">}}
121 \describe{
122 \item{\code{value}}{Single-element numeric vector; the value at which to set the
123 progress bar, relative to \code{min} and \code{max}. \code{NULL} hides the progress
124 bar, if it is currently visible.}
125
126 \item{\code{message}}{A single-element character vector; the message to be
127 displayed to the user, or \code{NULL} to hide the current message (if any).}
128
129 \item{\code{detail}}{A single-element character vector; the detail message to be
130 displayed to the user, or \code{NULL} to hide the current detail message (if
131 any). The detail message will be shown with a de-emphasized appearance
132 relative to \code{message}.}
133 }
134 \if{html}{\out{</div>}}
135 }
136 }
137 \if{html}{\out{<hr>}}
138 \if{html}{\out{<a id="method-Progress-inc"></a>}}
139 \if{latex}{\out{\hypertarget{method-Progress-inc}{}}}
140 \subsection{Method \code{inc()}}{
141 Like \code{set}, this updates the progress panel. The difference
142 is that \code{inc} increases the progress bar by \code{amount}, instead of
143 setting it to a specific value.
144 \subsection{Usage}{
145 \if{html}{\out{<div class="r">}}\preformatted{Progress$inc(amount = 0.1, message = NULL, detail = NULL)}\if{html}{\out{</div>}}
146 }
147
148 \subsection{Arguments}{
149 \if{html}{\out{<div class="arguments">}}
150 \describe{
151 \item{\code{amount}}{For the \code{inc()} method, a numeric value to increment the
152 progress bar.}
153
154 \item{\code{message}}{A single-element character vector; the message to be
155 displayed to the user, or \code{NULL} to hide the current message (if any).}
156
157 \item{\code{detail}}{A single-element character vector; the detail message to be
158 displayed to the user, or \code{NULL} to hide the current detail message (if
159 any). The detail message will be shown with a de-emphasized appearance
160 relative to \code{message}.}
161 }
162 \if{html}{\out{</div>}}
163 }
164 }
165 \if{html}{\out{<hr>}}
166 \if{html}{\out{<a id="method-Progress-getMin"></a>}}
167 \if{latex}{\out{\hypertarget{method-Progress-getMin}{}}}
168 \subsection{Method \code{getMin()}}{
169 Returns the minimum value.
170 \subsection{Usage}{
171 \if{html}{\out{<div class="r">}}\preformatted{Progress$getMin()}\if{html}{\out{</div>}}
172 }
173
174 }
175 \if{html}{\out{<hr>}}
176 \if{html}{\out{<a id="method-Progress-getMax"></a>}}
177 \if{latex}{\out{\hypertarget{method-Progress-getMax}{}}}
178 \subsection{Method \code{getMax()}}{
179 Returns the maximum value.
180 \subsection{Usage}{
181 \if{html}{\out{<div class="r">}}\preformatted{Progress$getMax()}\if{html}{\out{</div>}}
182 }
183
184 }
185 \if{html}{\out{<hr>}}
186 \if{html}{\out{<a id="method-Progress-getValue"></a>}}
187 \if{latex}{\out{\hypertarget{method-Progress-getValue}{}}}
188 \subsection{Method \code{getValue()}}{
189 Returns the current value.
190 \subsection{Usage}{
191 \if{html}{\out{<div class="r">}}\preformatted{Progress$getValue()}\if{html}{\out{</div>}}
192 }
193
194 }
195 \if{html}{\out{<hr>}}
196 \if{html}{\out{<a id="method-Progress-close"></a>}}
197 \if{latex}{\out{\hypertarget{method-Progress-close}{}}}
198 \subsection{Method \code{close()}}{
199 Removes the progress panel. Future calls to \code{set} and
200 \code{close} will be ignored.
201 \subsection{Usage}{
202 \if{html}{\out{<div class="r">}}\preformatted{Progress$close()}\if{html}{\out{</div>}}
203 }
204
205 }
206 \if{html}{\out{<hr>}}
207 \if{html}{\out{<a id="method-Progress-clone"></a>}}
208 \if{latex}{\out{\hypertarget{method-Progress-clone}{}}}
209 \subsection{Method \code{clone()}}{
210 The objects of this class are cloneable with this method.
211 \subsection{Usage}{
212 \if{html}{\out{<div class="r">}}\preformatted{Progress$clone(deep = FALSE)}\if{html}{\out{</div>}}
213 }
214
215 \subsection{Arguments}{
216 \if{html}{\out{<div class="arguments">}}
217 \describe{
218 \item{\code{deep}}{Whether to make a deep clone.}
219 }
220 \if{html}{\out{</div>}}
221 }
222 }
223 }