Debian Codegraph @

man/shinyOptions.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/shiny-options.R
3 \name{getShinyOption}
4 \alias{getShinyOption}
5 \alias{shinyOptions}
6 \alias{shiny-options}
7 \title{Get or set Shiny options}
8 \usage{
9 getShinyOption(name, default = NULL)
10
11 shinyOptions(...)
12 }
13 \arguments{
14 \item{name}{Name of an option to get.}
15
16 \item{default}{Value to be returned if the option is not currently set.}
17
18 \item{...}{Options to set, with the form \code{name = value}.}
19 }
20 \description{
21 There are two mechanisms for working with options for Shiny. One is the
22 \code{\link[=options]{options()}} function, which is part of base R, and the other is the
23 \code{shinyOptions()} function, which is in the Shiny package. The reason for
24 these two mechanisms is has to do with legacy code and scoping.
25
26 The \code{\link[=options]{options()}} function sets options globally, for the duration of the R
27 process. The \code{\link[=getOption]{getOption()}} function retrieves the value of an option. All
28 shiny related options of this type are prefixed with \code{"shiny."}.
29
30 The \code{shinyOptions()} function sets the value of a shiny option, but unlike
31 \code{options()}, it is not always global in scope; the options may be scoped
32 globally, to an application, or to a user session in an application,
33 depending on the context. The \code{getShinyOption()} function retrieves a value
34 of a shiny option. Currently, the options set via \code{shinyOptions} are for
35 internal use only.
36 }
37 \section{Options with \code{options()}}{
38
39
40 \describe{
41 \item{shiny.autoreload (defaults to \code{FALSE})}{If \code{TRUE} when a Shiny app is launched, the
42 app directory will be continually monitored for changes to files that
43 have the extensions: r, htm, html, js, css, png, jpg, jpeg, gif. If any
44 changes are detected, all connected Shiny sessions are reloaded. This
45 allows for fast feedback loops when tweaking Shiny UI.
46
47 Monitoring for changes is no longer expensive, thanks to the \pkg{watcher}
48 package, but this feature is still intended only for development.
49
50 You can customize the file patterns Shiny will monitor by setting the
51 shiny.autoreload.pattern option. For example, to monitor only \code{ui.R}:
52 \code{options(shiny.autoreload.pattern = glob2rx("ui.R"))}.
53
54 As mentioned above, Shiny no longer polls watched files for changes.
55 Instead, using \pkg{watcher}, Shiny is notified of file changes as they
56 occur. These changes are batched together within a customizable latency
57 period. You can adjust this period by setting
58 \code{options(shiny.autoreload.interval = 2000)} (in milliseconds). This value
59 converted to seconds and passed to the \code{latency} argument of
60 \code{\link[watcher:watcher]{watcher::watcher()}}. The default latency is 250ms.}
61 \item{shiny.deprecation.messages (defaults to \code{TRUE})}{This controls whether messages for
62 deprecated functions in Shiny will be printed. See
63 \code{\link[=shinyDeprecated]{shinyDeprecated()}} for more information.}
64 \item{shiny.error (defaults to \code{NULL})}{This can be a function which is called when an error
65 occurs. For example, \code{options(shiny.error=recover)} will result a
66 the debugger prompt when an error occurs.}
67 \item{shiny.fullstacktrace (defaults to \code{FALSE})}{Controls whether "pretty" (\code{FALSE}) or full
68 stack traces (\code{TRUE}) are dumped to the console when errors occur during Shiny app execution.
69 Pretty stack traces attempt to only show user-supplied code, but this pruning can't always
70 be done 100\% correctly.}
71 \item{shiny.host (defaults to \code{"127.0.0.1"})}{The IP address that Shiny should listen on. See
72 \code{\link[=runApp]{runApp()}} for more information.}
73 \item{shiny.jquery.version (defaults to \code{3})}{The major version of jQuery to use.
74 Currently only values of \code{3} or \code{1} are supported. If \code{1}, then jQuery 1.12.4 is used. If \code{3},
75 then jQuery 3.7.1 is used.}
76 \item{shiny.json.digits (defaults to \code{I(16)})}{Max number of digits to use when converting
77 numbers to JSON format to send to the client web browser. Use \code{\link[=I]{I()}} to specify significant digits.
78 Use \code{NA} for max precision.}
79 \item{shiny.launch.browser (defaults to \code{interactive()})}{A boolean which controls the default behavior
80 when an app is run. See \code{\link[=runApp]{runApp()}} for more information.}
81 \item{shiny.mathjax.url (defaults to \code{"https://mathjax.rstudio.com/latest/MathJax.js"})}{
82 The URL that should be used to load MathJax, via \code{\link[=withMathJax]{withMathJax()}}.}
83 \item{shiny.mathjax.config (defaults to \code{"config=TeX-AMS-MML_HTMLorMML"})}{The querystring
84 used to load MathJax, via \code{\link[=withMathJax]{withMathJax()}}.}
85 \item{shiny.maxRequestSize (defaults to 5MB)}{This is a number which specifies the maximum
86 web request size, which serves as a size limit for file uploads.}
87 \item{shiny.minified (defaults to \code{TRUE})}{By default
88 Whether or not to include Shiny's JavaScript as a minified (\code{shiny.min.js})
89 or un-minified (\code{shiny.js}) file. The un-minified version is larger,
90 but can be helpful for development and debugging.}
91 \item{shiny.port (defaults to a random open port)}{A port number that Shiny will listen on. See
92 \code{\link[=runApp]{runApp()}} for more information.}
93 \item{shiny.reactlog (defaults to \code{FALSE})}{If \code{TRUE}, enable logging of reactive events,
94 which can be viewed later with the \code{\link[=reactlogShow]{reactlogShow()}} function.
95 This incurs a substantial performance penalty and should not be used in
96 production.}
97 \item{shiny.sanitize.errors (defaults to \code{FALSE})}{If \code{TRUE}, then normal errors (i.e.
98 errors not wrapped in \code{safeError}) won't show up in the app; a simple
99 generic error message is printed instead (the error and stack trace printed
100 to the console remain unchanged). If you want to sanitize errors in general, but you DO want a
101 particular error \code{e} to get displayed to the user, then set this option
102 to \code{TRUE} and use \code{stop(safeError(e))} for errors you want the
103 user to see.}
104 \item{shiny.stacktraceoffset (defaults to \code{TRUE})}{If \code{TRUE}, then Shiny's printed stack
105 traces will display srcrefs one line above their usual location. This is
106 an arguably more intuitive arrangement for casual R users, as the name
107 of a function appears next to the srcref where it is defined, rather than
108 where it is currently being called from.}
109 \item{shiny.suppressMissingContextError (defaults to \code{FALSE})}{Normally, invoking a reactive
110 outside of a reactive context (or \code{\link[=isolate]{isolate()}}) results in
111 an error. If this is \code{TRUE}, don't error in these cases. This
112 should only be used for debugging or demonstrations of reactivity at the
113 console.}
114 \item{shiny.testmode (defaults to \code{FALSE})}{If \code{TRUE}, then various features for testing Shiny
115 applications are enabled.}
116 \item{shiny.snapshotsortc (defaults to \code{FALSE})}{If \code{TRUE}, test snapshot keys
117 for \pkg{shinytest} will be sorted consistently using the C locale. Snapshots
118 retrieved by \pkg{shinytest2} will always sort using the C locale.}
119 \item{shiny.trace (defaults to \code{FALSE})}{Print messages sent between the R server and the web
120 browser client to the R console. This is useful for debugging. Possible
121 values are \code{"send"} (only print messages sent to the client),
122 \code{"recv"} (only print messages received by the server), \code{TRUE}
123 (print all messages), or \code{FALSE} (default; don't print any of these
124 messages).}
125 \item{shiny.autoload.r (defaults to \code{TRUE})}{If \code{TRUE}, then the R/
126 of a shiny app will automatically be sourced.}
127 \item{shiny.useragg (defaults to \code{TRUE})}{Set to \code{FALSE} to prevent PNG rendering via the
128 ragg package. See \code{\link[=plotPNG]{plotPNG()}} for more information.}
129 \item{shiny.usecairo (defaults to \code{TRUE})}{Set to \code{FALSE} to prevent PNG rendering via the
130 Cairo package. See \code{\link[=plotPNG]{plotPNG()}} for more information.}
131 \item{shiny.devmode (defaults to \code{NULL})}{Option to enable Shiny Developer Mode. When set,
132 different default \code{getOption(key)} values will be returned. See \code{\link[=devmode]{devmode()}} for more details.}
133 \item{shiny.otel.collect (defaults to \code{Sys.getenv("SHINY_OTEL_COLLECT", "all")})}{Determines how Shiny will interact with OpenTelemetry.
134
135 Supported values:
136 \itemize{
137 \item \code{"none"} - No Shiny OpenTelemetry tracing.
138 \item \code{"session"} - Adds session start/end spans.
139 \item \code{"reactive_update"} - Spans for any synchronous/asynchronous reactive
140 update. (Includes \code{"session"} features).
141 \item \code{"reactivity"} - Spans for all reactive expressions and logs for setting
142 reactive vals and values. (Includes \code{"reactive_update"} features). This
143 option must be set when creating any reactive objects that should record
144 OpenTelemetry spans / logs. See \code{\link[=withOtelCollect]{withOtelCollect()}} and
145 \code{\link[=localOtelCollect]{localOtelCollect()}} for ways to set this option locally when creating
146 your reactive expressions.
147 \item \code{"all"} - All Shiny OpenTelemetry tracing. Currently equivalent to
148 \code{"reactivity"}.
149 }
150
151 This option is useful for debugging and profiling while in production. This
152 option will only be useful if the \code{otelsdk} package is installed and
153 \code{otel::is_tracing_enabled()} returns \code{TRUE}. Please have any OpenTelemetry
154 environment variables set before loading any relevant R packages.
155
156 To set this option locally within a specific part of your Shiny
157 application, see \code{\link[=withOtelCollect]{withOtelCollect()}} and \code{\link[=localOtelCollect]{localOtelCollect()}}.}
158 \item{shiny.otel.sanitize.errors (defaults to \code{TRUE})}{If \code{TRUE}, fatal and unhandled errors will be sanitized before being sent to the OpenTelemetry backend. The default value of \code{TRUE} is set to avoid potentially sending sensitive information to the OpenTelemetry backend. If you want the full error message and stack trace to be sent to the OpenTelemetry backend, set this option to \code{FALSE} or use \code{safeError(e)}.}
159 }
160 }
161
162 \section{Scoping for \code{shinyOptions()}}{
163
164
165 There are three levels of scoping for \code{shinyOptions()}: global,
166 application, and session.
167
168 The global option set is available by default. Any calls to
169 \code{shinyOptions()} and \code{getShinyOption()} outside of an app will access the
170 global option set.
171
172 When a Shiny application is run with \code{\link[=runApp]{runApp()}}, the global option set is
173 duplicated and the new option set is available at the application level. If
174 options are set from \code{global.R}, \code{app.R}, \code{ui.R}, or \code{server.R} (but
175 outside of the server function), then the application-level options will be
176 modified.
177
178 Each time a user session is started, the application-level option set is
179 duplicated, for that session. If the options are set from inside the server
180 function, then they will be scoped to the session.
181 }
182
183 \section{Options with \code{shinyOptions()}}{
184
185
186 There are a number of global options that affect Shiny's behavior. These
187 can be set globally with \code{options()} or locally (for a single app) with
188 \code{shinyOptions()}.
189
190 \describe{ \item{cache}{A caching object that will be used by
191 \code{\link[=renderCachedPlot]{renderCachedPlot()}}. If not specified, a \code{\link[cachem:cache_mem]{cachem::cache_mem()}} will be
192 used.} }
193 }
194