Build the call tree of a running Shiny app
call_tree_app.Rdcall_tree_app() inspects a shiny::shinyApp() object at runtime,
rather than parsing source files on disk. It extracts the server
function, collects every function visible in the server's enclosing
environment chain, and builds the call graph among them, in the same
shape call_stack() returns.
call_tree_app() never calls into the shiny package itself; it only
inspects the structure of the shiny.appobj you pass in, so stackcallr
does not need shiny installed unless you're building one.
This only works on a shiny.appobj. It can't inspect the
ShinyAppHandle returned by shiny::startApp(): that handle is a
runtime control object (stop()/status()/url()/result()) for an
app that may be running in a separate process, and it exposes no
reference back to the app's UI, server, or environment. Pass the
shiny.appobj itself, before calling startApp() on it.
Arguments
- app
A
shiny.appobj, as returned byshiny::shinyApp()orshiny::shinyAppDir(). Not theShinyAppHandlereturned byshiny::startApp().- app_fun
Character scalar; label used for the root node. The app object doesn't store the name of its own launch function, so this is display text only. Default
"app".- ui_fun
Character scalar or
NULL; name of the UI function. WhenNULL(the default),call_tree_app()tries to recover it automatically, which only works whenuiwas passed toshiny::shinyApp()as an unevaluated function (shinyApp(ui = app_ui, ...)). Ifuiwas pre-evaluated (shinyApp(ui = app_ui(), ...)), supply the name explicitly so the UI branch is included.- server_fun
Character scalar or
NULL; name of the server function. WhenNULL(the default), the name is inferred by comparing function bodies against those visible in the server's environment.- modules_only
Logical; see
call_tree_dir(). DefaultFALSE.
Value
An object of class call_stack (see call_stack()).
See also
call_tree_dir() for the file-based equivalent.
Examples
if (FALSE) { # \dontrun{
app <- shiny::shinyApp(ui = app_ui, server = app_server)
call_tree_app(app)
call_tree_app(app, modules_only = TRUE)
} # }