Description Usage Arguments Details Value Examples
These functions allow you to reactive multiple reactive elements based on their names
1 2 3 4 5 6 7 | reactive_contains(match, valueExpr, input, ignore.case = TRUE)
reactive_starts_with(match, valueExpr, input, ignore.case = TRUE)
reactive_ends_with(match, valueExpr, input, ignore.case = TRUE)
reactive_one_of(elements, valueExpr, input, ignore.case = TRUE)
|
match |
character |
valueExpr |
The expression that produces the return value of the
|
input |
reactive object |
ignore.case |
logical If TRUE ignores case when matching names, Default: TRUE |
elements |
character vector contains names of elements in the reactive object |
The internal shiny::eventReactive is passed a variable var_
that contains the matched element name in the reactive object input. That variable
can be defined as a paramter of valueExpr.
observer reference class object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## Not run:
if(interactive()){
ui <- shiny::fluidPage(
shiny::column(width = 6,
lapply(1:4,FUN = function(x){
shiny::actionButton(inputId = sprintf('btn_%02d',x),label = 'update')
})
)
)
server <- shiny::shinyServer(function(input, output,session) {
out <- shinyselect::reactive_one_of(c('btn_01','btn_03'),
valueExpr = function(var_){
runif(as.numeric(gsub('[^0-9]','',var_)))
},input)
shinyselect::observe_contains(match = 'btn_0(1|3)',
handlerExpr = function(var_){
print(out()[[var_]]())
},
input = out()
)
})
shiny::shinyApp(ui = ui, server = server)
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.