title: Keeping Client State Up-To-Date In Reagent / Clojurescript
body: <p>I am not sure on the best way to go about this:  </p>
  
  <p>I have a web application I am writing which implements basic CRUD functionality for a number of "Project" objects.   So, a user can create his/her own set of Projects. </p>
  
  <p>I have written a REST API for adding / removing / listing the projects, and I have written a Reagent front-end client.  The client's projects are held in a reagent atom (ratom), as you would expect.</p>
  
  <p>This is where it gets interesting.   </p>
  
  <p>In all the tutorials I have seen, it shows you how to update the ratom and your GUI will update automatically.  I have that, that works.  </p>
  
  <p>What I am currently doing is, at the point of updating the client state, I make my REST POST call to update the server state on the database.  </p>
  
  <p>But, this doesn't feel right.  I am now storing state in two places: on the client and on the server, and both could be different.  </p>
  
  <p>If I were implementing this as a plain old web page, the server would send a page back to the client with the latest state of the database in it.  But, state already exists on the client in the ratom, and I don't know how I should synchronise it.</p>
  
  <p>Should I make another call to the server (a GET request) after the initial POST is successful?  This could replace the contents of the ratom. Then I'm making two requests.. which seems wasteful.</p>
  
  <p>Or is the best practice to use something like <strong>chord</strong> or <strong>sente</strong> to manage the client state asynchronously.  This would be better, as it would mean changes from other users would be instantaneously refreshed on the client side.   But, I can't see any tutorials demonstrating react with either of these so maybe I am on the wrong track.</p>
  
  <p>So the question is simply, how should one combine react with REST?</p>
  
  <p>thanks</p>