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


eventReactives are similar to reactives, they are constructed as follows:

eventReactive( event {
code to run

eventReactives are not dependent on all reactive expressions in their body ('code to run' in the snippet above). Instead, they are only dependent on the expressions specified in the event section.

In the example below, we have added a submit button, and created an eventReactive. Whenever input$user_text changes, the eventReactive is not invalidated, since the eventReactive is only dependent on the actionButton input$submit. Whenever that button is pressed, text_reactive and subsequently output$text are invalidated, and will be recalulated based on the updated input$user_text.


ui <- fluidPage(
  headerPanel("Example eventReactive"),
    # input field
    textInput("user_text", label = "Enter some text:", placeholder = "Please enter some text."),

    # submit button
    actionButton("submit", label = "Submit"),
    # display text output

server <- function(input, output) {
  # reactive expression
  text_reactive <- eventReactive( input$submit, {
  # text output
  output$text <- renderText({

shinyApp(ui = ui, server = server)