sync_shiny_inputs: Synchronize Shiny Inputs

Description Usage Arguments Value Examples

View source: R/shiny-syncInputs.R

Description

Synchronize Shiny Inputs

Usage

1
2
3
4
5
6
7
8
sync_shiny_inputs(
  input,
  session,
  inputIds,
  uniform = rep("I", length(inputIds)),
  updates,
  snap = 250
)

Arguments

input, session

shiny reactive objects

inputIds

input ids to be synchronized

uniform

functions, equaling to length of inputIds, converting inputs to a uniform values

updates

functions, equaling to length of inputIds, updating input values

snap

numeric, milliseconds to defer the changes

Value

none.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(shiny)

ui <- fluidPage(
  textInput('a', 'a', value = 'a'),
  sliderInput('b', 'b', value = 1, min = 0, max = 1000)
)

server <- function(input, output, session) {
  sync_shiny_inputs(input, session, inputIds = c('a', 'b'), uniform = list(
    function(a){as.numeric(a)},
    'I'
  ), updates = list(
    function(a){updateTextInput(session, 'a', value = a)},
    function(b){updateSliderInput(session, 'b', value = b)}
  ))

}

if( interactive() ){
  shinyApp(ui, server)
}

dipsaus documentation built on Sept. 6, 2021, 5:08 p.m.