File tree Expand file tree Collapse file tree 2 files changed +21
-19
lines changed Expand file tree Collapse file tree 2 files changed +21
-19
lines changed Original file line number Diff line number Diff line change @@ -44,15 +44,29 @@ load_main_module <- function() {
44
44
}
45
45
46
46
as_top_level <- function (app_env ) {
47
- # Necessary to avoid infinite recursion / bugs due to lazy evaluation:
48
- # https://adv-r.hadley.nz/function-factories.html?q=force#forcing-evaluation
49
- force(app_env )
47
+ list (
48
+ # Wrap the UI in a function to support Shiny bookmarking.
49
+ ui = function (request ) app_env $ main $ ui(" app" ),
50
+ server = fix_server_reloading(function (input , output ) {
51
+ app_env $ main $ server(" app" )
52
+ })
53
+ )
54
+ }
55
+
56
+ fix_server_reloading <- function (server ) {
57
+ reparse(curly_wrap(server ))
58
+ }
50
59
51
- # The actual function must be sourced with `keep.source = TRUE` for reloading to work:
52
- # https://github.com/Appsilon/rhino/issues/157
53
- wrap <- source( fs :: path_package( " rhino " , " as_top_level.R " ), keep.source = TRUE ) $ value
60
+ reparse <- function ( f ) {
61
+ eval(parse( text = deparse( f )), envir = environment( f ))
62
+ }
54
63
55
- wrap(app_env )
64
+ curly_wrap <- function (f ) {
65
+ wrapped <- function () {
66
+ do.call(f , as.list(match.call())[- 1 ])
67
+ }
68
+ formals(wrapped ) <- formals(f )
69
+ wrapped
56
70
}
57
71
58
72
load_app <- function () {
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments