title: Unique Realm container objects
body: <p>I implemented real time sync following Realm's tasks demo app.</p>
  
  <p>There a dummy container is used, to hold a <code>List</code> with the models.</p>
  
  <p>The demo app doesn't seem to support offline usage.</p>
  
  <p>I wondered what happens when, given this setup, I start the app on an online as well as an offline device and then go online with the offline device.</p>
  
  <p>My initial expectation was that I'd end with 2 containers (which would be an invalid state), but when I tested surprisingly there was only 1 container at the end.</p>
  
  <p>But sometimes I get 2 containers and haven't been able to identify what causes this.</p>
  
  <p>The question then is, how does this exactly work? I assume the reason that the container is normally not duplicated when I sync the offline device for the first time is that it's handled as the same object, maybe because it doesn't have a primary key or something? But then why is it sometimes duplicated? And what would be the best practice here? Do I maybe have to use a primary key or check after connecting if there's duplication and if yes do a manual merge of the containers?</p>