Replies: 1 comment
-
hey @KoderKow, Sorry for the late reply. I just pushed this repo that you might find interesting : https://github.com/ColinFay/golemexamples/tree/master/golemloadorder The idea is to log all the parts of the app, so that we can see how often a piece is executed. As far as I can tell, if you take the app.R and launch it inside multiple windows, the following parts are only executed once :
> shiny::runApp()
Warning in loadSupport(appDir, renv = sharedEnv, globalrenv = NULL) :
Loading R/ subdirectory for Shiny application, but this directory appears to contain an R package. Sourcing files in R/ may cause unexpected behavior.
── app.R ───────────────────────────────────────────────────────────────────────────────────
ℹ Loading golemloadorder
── run_app() ───────────────────────────────────────────────────────────────────────────────
Listening on http://127.0.0.1:6827
── app_ui() ────────────────────────────────────────────────────────────────────────────────
── golem_add_external_resources() ──────────────────────────────────────────────────────────
── mod_one_ui() ────────────────────────────────────────────────────────────────────────────
── app_server.R ────────────────────────────────────────────────────────────────────────────
── mod_one_server() ────────────────────────────────────────────────────────────────────────
── mod_one_server.moduleServer() ───────────────────────────────────────────────────────────
── mod_one_server.renderPlot() ─────────────────────────────────────────────────────────────
# NOTE : THIS IS THE MOMENT I OPENED A NEW WINDOW
── app_ui() ────────────────────────────────────────────────────────────────────────────────
── golem_add_external_resources() ──────────────────────────────────────────────────────────
── mod_one_ui() ────────────────────────────────────────────────────────────────────────────
── app_server.R ────────────────────────────────────────────────────────────────────────────
── mod_one_server() ────────────────────────────────────────────────────────────────────────
── mod_one_server.moduleServer() ───────────────────────────────────────────────────────────
── mod_one_server.renderPlot() ───────────────────────────────────────────────────────────── Also, the rnorm() from app.R & run_app.R are the same for all sessions, the one from the module is different for every session. So basically, as far as I can tell, everything inside app.R & run_app.R is executed one time by R session, meaning that everything defined here will be shared across all shiny sessions (as long as they happen inside the same R session). Let me know if that answers your question. Colin |
Beta Was this translation helpful? Give feedback.
-
Hello friends! I have a question that I am having a hard time finding resources for.
run_app()
is executedrun_app()
function and globally assign it (example"my_data <<- read_data()
), it will make it available in other sessionsrun_app()
is not executedI am very interested in your thoughts on this. Finding any discussion about this topic for Shiny, in general, is difficult!
Thanks, appreciate your work!
Beta Was this translation helpful? Give feedback.
All reactions