-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathget_golem_options.Rd
67 lines (57 loc) · 1.29 KB
/
get_golem_options.Rd
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/with_opt.R
\name{get_golem_options}
\alias{get_golem_options}
\title{Get all or one golem options}
\usage{
get_golem_options(which = NULL)
}
\arguments{
\item{which}{NULL (default), or the name of an option}
}
\value{
The value of the option.
}
\description{
This function is to be used inside the
server and UI from your app, in order to call the
parameters passed to \code{run_app()}.
}
\examples{
# Define and use golem_options
if (interactive()) {
# 1. Pass parameters directly to `run_app`
run_app(
title = "My Golem App",
content = "something"
)
# 2. Get the values
# 2.1 from the UI side
h1(get_golem_options("title"))
# 2.2 from the server-side
output$param <- renderPrint({
paste("param content = ", get_golem_options("content"))
})
output$param_full <- renderPrint({
get_golem_options() # list of all golem options as a list.
})
# 3. If needed, to set default value, edit `run_app` like this :
run_app <- function(
title = "this",
content = "that",
...
) {
with_golem_options(
app = shinyApp(
ui = app_ui,
server = app_server
),
golem_opts = list(
title = title,
content = content,
...
)
)
}
}
}