title: Android MVVM/Repository how to force LiveData to update from repository?
body: <p>here is my problem:</p>
  
  <p>i have used MVVM/Repository design pattern like this:</p>
  
  <p>Activity -(Observes)-> ViewModel's LiveData -> Repository -> WebService API (GET Resource)</p>
  
  <p>i have another calls for <strong>UPDATING</strong> <em>Resource</em> to WebService.</p>
  
  <p>Problem:</p>
  
  <p><strong>after changing resource on the server. how i can make the <em>Resource</em> livedata to update itself with new servers data</strong></p>
  
  <p>i want to force it fetch data from server again because some other data may have been changed.
  and i dont want to use local database (Room) and change it because my server data might be changed. and they need to fetch each time.</p>
  
  <p>The Only solution passed my Mind was to create a Livedata Source (as dataVersion) to it.
  and increment it after every update like this (pseudo code):</p>
  
  <pre><code>dataVersion = new MutableLiveData();
  dataVersion.setValue(0);
  // my repository get method hasnt anything to do with the dataVersion.
  myData = Transformation.switchmap(dataVersion, versionNum -&gt; { WebServiceRepo.getList() });
  </code></pre>
  
  <p>and how dataVersion should get updated in ViewModel.</p>