title: Action button and observeEvent
body: <p>I want an button to triggers an action on a prespecified non-reactive variable <code>x</code>. Each time the button is hit <code>x  &lt;- x + 1</code> shall be executed. To check if it was done correctly the result shall be displayed. 
  To achieve this I tried  <code>observeEvent()</code>. But it is doing what it should only once. How does it work properly?</p>
  
  <p>It seems that <code>rv</code> is only available within the <code>observeEvent()</code> function. If <code>output$text_2 &lt;- renderText({ rv$a })</code> is placed outside of <code>observeEvent()</code> an error occurs. How can I use something done within <code>observeEvent()</code> outside of it?</p>
  
  <pre><code>library(shiny)
  x  &lt;- 0
  
  ui &lt;- fluidPage(
  
    actionButton(inputId = "action", 
                 label = "action"),
    textOutput("text_1"),
    textOutput("text_2")
  
  )
  
  server &lt;- function(input, output) {
  
    output$text_1&lt;- renderText({ input$action })
  
    observeEvent(input$action, {
                 x  &lt;- x + 1 
                 rv &lt;- reactiveValues(a = x)
                 output$text_2 &lt;- renderText({ rv$a })
                 })
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>