title: CQRS and commands debouncing
body: <p>I have the following task:</p>
  
  <ol>
  <li>Our current architecture is Web SPA with CQRS and MVVM. We have
  commands, queries and SingnalR as message bus.  </li>
  <li>Users can select, move, resize divs on the same workspace from several web browsers simultaneously.  </li>
  <li>Each div is binded to the approprite ViewModel. Each ViewModel has it's own query to refresh. Each ViewModel subscribed to business events and refresh the whole state after it.</li>
  </ol>
  
  <p>Lets image that User is doing the following steps:</p>
  
  <ol>
  <li>Select div (SelectWidgetCommand sent)</li>
  <li>Move div to x=10. (ChangePositionCommand sent)</li>
  <li>Move div to x=100. (ChangePositionCommand sent)</li>
  </ol>
  
  <p>The problem is that the commands are fire-and-forget and the User may receive event WidgetSelectedEvent during the Step 3 but the ChangePositionCommand may not be handled yet. So the User will receive the old x position and the div will move to the old position.</p>
  
  <p>What is the best practice to handle this kind of issues?</p>
  
  <p>What we are now doing is splitting the DivViewModel into two divs: SelectionViewModel, PositionViewModel. Each ViewModel has it's own query to refresh and different events to handle. Also we consider using debounce and rolling buffer for commands handling.</p>