Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around server reloading issues #297

Merged
merged 2 commits into from Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/app.R
Expand Up @@ -46,11 +46,11 @@ as_top_level <- function(shiny_module) {
# https://adv-r.hadley.nz/function-factories.html?q=force#forcing-evaluation
force(shiny_module)

list(
# Wrap the UI in a function to support Shiny bookmarking.
ui = function(request) shiny_module$ui("app"),
server = function(input, output) shiny_module$server("app")
)
# The actual function must be sourced with `keep.source = TRUE` for reloading to work:
# https://github.com/Appsilon/rhino/issues/157
wrap <- source(fs::path_package("rhino", "as_top_level.R"), keep.source = TRUE)$value

wrap(shiny_module)
}

attach_head_tags <- function(ui) {
Expand Down
10 changes: 10 additions & 0 deletions inst/as_top_level.R
@@ -0,0 +1,10 @@
function(shiny_module) {
kamilzyla marked this conversation as resolved.
Show resolved Hide resolved
list(
# Wrap the UI in a function to support Shiny bookmarking.
ui = function(request) shiny_module$ui("app"),
# The curly braces below are essential: https://github.com/Appsilon/rhino/issues/157
server = function(input, output) {
shiny_module$server("app")
}
)
}