R Reactivity: observe running more times than expected
<p>I am new to shiny and I need to understand a thing that's driving mad: why this code runs 3 times instead of 1</p>

<pre><code>observe({ duplicate() })


duplicate = function() {
  for (inp in names(input)[grepl("^box", names(input))]) {
    inpCode = substr(inp, 5, nchar(inp))
    value = eval(parse(text = paste("input$", inp, sep = "")))

    if (is.na(value)){
      value = eval(parse(text = paste("input$secondbox", inpCode, sep = "")))
    }

    updateNumericInput(session, paste("thirdbox", inpCode, sep = ""), value = value)
  }
}
</code></pre>

<p>I have seen that it is related to the fact that I am reading from 3 different inputs within an observe but just updating once so it should run only once. What am I missing here? Thanks.</p>