Previews a SIA module in a standalone development environment. See the details below.
preview_module(
module_id = NULL,
ui_imports = NULL,
server_imports = NULL,
ui_elements = sia_head_tag(),
save_and_document = TRUE,
load = TRUE,
proj = curr_proj(),
...
)Shiny app object of class shiny.appobj.
character, name of the module to preview (including the
prefix). If NULL (the default), all modules discovered by get_modules()
are listed and you are asked to pick one.
list, UI objects exported from the {ShinyItemAnalysis}
app. Not used at the moment.
list, reactive objects exported from the
{ShinyItemAnalysis} app. See the Details.
elements to include in fluidPage, preferably packed in
tagList().
logical, whether to save all unsaved files (only available in RStudio)
and document the package. Defaults to TRUE. Note
that documenting the package is necessary if you use any functions from
external packages (to produce the NAMESPACE).
logical, whether to load your package
before running the module preview. Defaults to TRUE. Note that you have
to load the package by yourself or install it in the usual way if you set
this to FALSE.
character, a path to the project. Defaults to current project.
Arguments passed on to shiny::shinyApp
onStartA function that will be called before the app is actually run.
This is only needed for shinyAppObj, since in the shinyAppDir
case, a global.R file can be used for this purpose.
optionsNamed options that should be passed to the runApp call
(these can be any of the following: "port", "launch.browser", "host", "quiet",
"display.mode" and "test.mode"). You can also specify width and
height parameters which provide a hint to the embedding environment
about the ideal height/width for the app.
uiPatternA regular expression that will be applied to each GET
request to determine whether the ui should be used to handle the
request. Note that the entire request path must match the regular
expression in order for the match to be considered successful.
enableBookmarkingCan be one of "url", "server", or
"disable". The default value, NULL, will respect the setting from
any previous calls to enableBookmarking(). See enableBookmarking()
for more information on bookmarking your app.
The function takes module's function bindings and puts (or evaluates) them
inside a bare bone shiny::shinyApp(). By default, a customized head tag is
injected in order to mimic the "environment" of full {ShinyItemAnalysis}
app. See sia_head_tag() for more details. Besides, a onSessionEnded hook
is set to call shiny::stopApp() after the client disconnects, so the
"process" is automatically quit after you close the preview in your browser
or RStudio viewer.
In order to use the function bindings, preview_module() attempts to
load your package without the actual installation by
default.
Note that you have to install the package as usual for
{ShinyItemAnalysis} to detect your modules.
{ShinyItemAnalysis} app
Note that this "emulated" preview environment is really meant to test the
basic UI layout and functionality and is not able to receive any object from
{ShinyItemAnalysis} app. However, you can pass any object like
{ShinyItemAnalysis} does to server_imports argument manually. For further
details and examples, please refer to vignette("imports", "SIAtools")
vignette.
Other module management functions:
add_module(),
get_modules(),
remove_module()
if (interactive()) {
preview_module()
}
Run the code above in your browser using DataLab