Reputation: 490
I've been trying to develop more advanced apps using this new golem package in R's Shiny and came across this golem_opts that might be interesting, but still haven't seen no one using it. Can someone give examples of options for this function? Thanks in advance.
#' Run the Shiny Application
#'
#' @export
#' @importFrom shiny shinyApp
#' @importFrom golem with_golem_options
run_app <- function(...) {
with_golem_options(
app = shinyApp(ui = app_ui, server = app_server),
golem_opts = list(...)
)
}
I expect to get more customizable apps through this new and exiting package called golem. Also, if possible, could you point some more advanced application running with golem besides the creator's of the package and tutorials? There is a lack of examples of this package out there.
Upvotes: 1
Views: 1305
Reputation: 5109
You can check an example here
These two examples of passing args are pretty useless here, but they are designed to give you a grasp of what it does.
This example though is intended to show that golem_opts
can be used in the UI and from the server side.
Other examples (from internal apps / client apps) include things like:
# Run the application
XXX::run_app(local = TRUE)
Then :
if (golem::get_golem_options("local")){
session$userData$mongo <- mongolite::mongo("XXX")
} else {
pass <- readRDS("~/.mongo_con")
URI <- sprintf(
"mongodb://%s:%s@%s/%s",
pass$USER,
pass$PASS,
pass$HOST,
pass$DB
)
session$userData$mongo <- mongolite::mongo("XXX", "XXX", url = URI)
}
# Run the application
XXX::run_app(mongo_db = "dev")
Then
session$userData$mongo <- mongolite::mongo(golem::get_golem_options("mongo_db"), "XXX")
# Run the application
XXX::run_app(rights = "admin")
Then
fluidPage(
tagList(
mod_base_ui("mod_base_1"),
if (golem::get_golem_options("mongo_db") == "admin"){
mod_admin_ui("mod_admin_ui"),
}
)
)
Let me know if that helps,
Colin
Ps: asking "SHOW ME THE CODE" and criticising the lack of documentation is pretty rude, btw. Both take a lot of time to write, most of this time coming from package developers' free time, so that you can use it for free.
Upvotes: 10