title: What is the correct way to implement objects that depend on each others change in Shiny R?
body: <p>I am trying to use <code>Shiny</code>. I am used to other programming languages (little bit of Java from App Development) where there are <code>onClick</code> Events, that trigger changes of other variables. I know that in MVC after a change in a view element, the controller can change the model variables in the background, then update the view without triggering an infinite loop of events on other elements.</p>
  
  <p>The code here works, but it triggers unnecessary and unwanted loops:</p>
  
  <p>If you choose 49 as n, dozens gets changed to 4, which changes n to 48, which changes dozens to 4, which doesn't trigger a change event.</p>
  
  <p>If you then change n to 49, dozens changes to 4, which doesn't trigger a change event.</p>
  
  <p>It seems wasteful and resource-intensive..</p>
  
  <pre class="lang-r prettyprint-override"><code>library(shiny)
  
  ui &lt;- fluidPage(
    sliderInput(inputId = "dozens",
                label = "Dozens:",
                min = 1,
                max = 5,
                value = 2),
    sliderInput(inputId = "n",
                label = "n:",
                min = 1,
                max = 60,
                value = 24)
  )
  server &lt;- function(input, output,session) {
    observeEvent(input$dozens,{
      updateSliderInput(session,"n",value=12*input$dozens)
    })
    observeEvent(input$n,{
      updateSliderInput(session,"dozens",value=round(input$n/12))
    })
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>What is the correct way?</p>