title: Paging Library with custom DataSource not updating row on Room update
body: <p>I have been implementing the new <a href="https://developer.android.com/topic/libraries/architecture/paging/" rel="noreferrer">Paging Library</a> with a <a href="https://developer.android.com/reference/android/support/v7/widget/RecyclerView" rel="noreferrer">RecyclerView</a> with an app built on top of the <a href="https://developer.android.com/topic/libraries/architecture/" rel="noreferrer">Architecture Components</a>.</p>
  
  <p>The data to fill the list is obtained from the <a href="https://developer.android.com/topic/libraries/architecture/room" rel="noreferrer">Room</a> database. In fact, it is fetched from the network, stored on the local database and provided to the list.</p>
  
  <p>In order to provide the necessary data to build the list, I have implemented my own custom <a href="https://developer.android.com/reference/android/arch/paging/PageKeyedDataSource" rel="noreferrer">PageKeyedDataSource</a>. Everything works as expected except for one little detail. Once the list is displayed, if any change occurs to the data of a list's row element, it is not automatically updated. So, if for example my list is showing a list of items which have a field <em>name</em>, and suddenly, this field is updated in the local Room database for a certain row item, the list does not update the row UI automatically.</p>
  
  <p>This behaviour only happens when using a custom DataSource unlike when the DataSource is obtained automatically from the <a href="https://developer.android.com/reference/android/arch/persistence/room/Dao" rel="noreferrer">DAO</a>, by returning a <a href="https://developer.android.com/reference/android/arch/paging/DataSource.Factory" rel="noreferrer">DataSource Factory</a> directly. However, I need to implement a custom DataSource. </p>
  
  <p>I know it could be updated by calling the <em>invalidate()</em> method on the DataSource to rebuild the updated list. However, if the app is showing 2 lists at a time (half screen each for example), and this item appears in both lists, it would be needed to call <em>invalidate()</em> for both lists separately.</p>
  
  <p>I have thought with a solution in which, instead of using an instance of the item's class to fill each <a href="https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ViewHolder" rel="noreferrer">ViewHolder</a>, it uses a <a href="https://developer.android.com/reference/android/arch/lifecycle/LiveData" rel="noreferrer">LiveData</a> wrapped version of it, to make each row observe for changes on its own item and update that row UI when necessary. Nevertheless, I see some downsides on this approach:</p>
  
  <ol>
  <li>A <a href="https://developer.android.com/reference/android/arch/lifecycle/LifecycleOwner" rel="noreferrer">LifeCycleOwner</a> (such as the Fragment containing the RecyclerView for example) must be passed to the <a href="https://developer.android.com/reference/android/arch/paging/PagedListAdapter" rel="noreferrer">PagedListAdapter</a> and then forward it to the ViewHolder in order to observe the LiveData wrapped item.</li>
  <li>A new observer will be registered for each list's new row, so I do not know at all if it has an excessive computational and memory cost, considering it would be done for every list in the app, which has a lot of lists in it.</li>
  <li>As the LifeCycleOwner observing the LiveData wrapped item would be, for example, the Fragment containing the RecyclerView, instead of the ViewHolder itself, the observer will be notified every time a change on that item occurs, even if the row containing that item is not even visible at that moment because the list has been scrolled, which seems to me like a waste of resources that could increase the computational cost unnecessarily.</li>
  </ol>
  
  <p>I do not know at all if, even considering those downsides, it could seem like a decent approach or, maybe, if any of you know any other cleaner and better way to manage it.</p>
  
  <p>Thank you in advance.</p>