This plugin enables setting block reactive state values from outside the
block expression server context. Blocks opt in to external control via the
external_ctrl argument to new_block(), which can be set to TRUE (all
constructor inputs) or a character vector of specific input names. The
default UI renders a shiny::textInput() for each externally controllable
input along with a submit shiny::actionButton(). Both the server and UI
can be replaced with custom implementations by passing alternate functions
to ctrl_block().
ctrl_block(server = ctrl_block_server, ui = ctrl_block_ui)ctrl_block_server(id, x, vars, data, eval)
ctrl_block_ui(id, x)
A plugin container inheriting from ctrl_block is returned by
ctrl_block(), while the UI component (i.e. ctrl_block_ui()) is
expected to return shiny UI (i.e. shiny::tagList()) and the server
component (i.e. ctrl_block_server()) is expected to return a value
that passes validation (i.e. TRUE or a reactive gate).
Server/UI for the plugin module
Namespace ID
Block
Reactive state values (list of reactiveVal objects keyed by
input name). block_name is included by the default block_server.block
even though it is not part of the block's expr_server state.
Input data paseed as list of reactive values
Reactive that evaluates the block expression against input data. May be used to validate that the new values produce a successful evaluation.
The default server validates submitted values by evaluating the block
expression (via the eval reactive) after updating state. On success,
a reactive gate is returned as TRUE, allowing downstream evaluation to
proceed. On failure, state values are reverted to their previous values,
the user is notified, and the gate is set to FALSE, which blocks
downstream evaluation until a subsequent successful submit.