Skip to contents

Must be called inside the main Shiny server function. Manages the reactive AlphaVarReportSpec and wires up all block controls, parameter sync, and export handlers.

Usage

av_server_report_builder(input, output, session, current_obj)

Arguments

input, output, session

Standard Shiny server arguments.

current_obj

A reactiveVal holding the current AlphaVarSet object.

Value

Invisibly, a list with the single element current_spec: the reactiveVal holding the live AlphaVarReportSpec. Called for its side effects, which register the block observers, the download handlers and the YAML load handler on input/output.

Examples

example_file <- system.file(
  "extdata", "bcl11a_rs1427407_example.csv",
  package = "AlphaVaR"
)
obj <- av_import_csv(example_file)
#> Reading bcl11a_rs1427407_example.csv ...

server <- function(input, output, session) {
  rb <- av_server_report_builder(
    input, output, session,
    current_obj = shiny::reactiveVal(obj)
  )
}

# shiny::testServer() drives the real observers without a browser. The
# builder starts from av_report_template_default(); the modal flow appends
# the selected block to that live spec.
shiny::testServer(server, {
  n_before <- length(rb$current_spec()$blocks)
  session$setInputs(
    rb_add_block = 1,
    rb_new_block_id = "plot_volcano",
    rb_confirm_add = 1
  )
  spec <- rb$current_spec()
  print(c(before = n_before, after = length(spec$blocks)))
  print(spec$blocks[[length(spec$blocks)]]$block_id)
})
#> Loading required package: shiny
#> before  after 
#>     27     28 
#> [1] "plot_volcano"