shiny reactive, reactiveValue and eventReactive, observe and observeEvent in Shiny reactiveValues


reactiveValues can be used to store objects, to which other expressions can take a dependency.

In the example below, a reactiveValues object is initialized with value "No text has been submitted yet.". A separate observer is created to update the reactiveValues object whenever the submit button is pressed. Note that the reactiveValues itself does not take a dependency on the expressions in its body.


ui <- fluidPage(
  headerPanel("Example reactiveValues"),
    # input field
    textInput("user_text", label = "Enter some text:", placeholder = "Please enter some text."),
    actionButton("submit", label = "Submit"),
    # display text output

server <- function(input, output) {
  # observe event for updating the reactiveValues
    text_reactive$text <- input$user_text
  # reactiveValues
  text_reactive <- reactiveValues(
    text = "No text has been submitted yet."
  # text output
  output$text <- renderText({

shinyApp(ui = ui, server = server)