title: Android - Correct way to write repository when app needs to periodically sync data with server
body: <p>What would be the best way to implement repository pattern:</p>
  
  <p><a href="https://i.stack.imgur.com/SPmwE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SPmwE.png" alt="Architecture"></a></p>
  
  <p>In the case when the app needs to sync with the server in some scheduled time, not on every UI data refresh/call to the repository?</p>
  
  <p>Should my repository, in that case, return always data from the database without bothering with REST API calls? Should I put my API calls into some WorkManager/background service?  </p>
  
  <p>In that way, the repository would be responsible to return local data, and some other service would be responsible to sync data with the server.
  Is that a bad architecture? </p>
  
  <p>Should I use another design pattern? </p>