title: Modifying PagedList in Android Paging Architecture library
body: <p>I'm currently looking into incorporating the Paging Architecture library (version <code>2.1.0-beta01</code> at the time of writing) into my app. One components is a list which allows the user to delete individual items from it. This list is network-only and caching localy with Room does not make sense.</p>
  
  <p><code>PagedList</code> is immutable and does not support modification. I have read that having a copy of the list which is than modified and returned as the new one is the way to go. The documentation states the same:</p>
  
  <blockquote>
    <p>If you have more granular update signals, such as a network API signaling an update to a single item in the list, it's recommended to load data from the network into memory. Then present that data to the PagedList via a DataSource that wraps an in-memory snapshot. Each time the in-memory copy changes, invalidate the previous DataSource, and a new one wrapping the new state of the snapshot can be created.</p>
  </blockquote>
  
  <p>I currently have the basic recommended implementation to show a simple list. My <code>DataSource</code> looks like this:</p>
  
  <pre><code>class MyDataSource&lt;SomeItem&gt; : PageKeyedDataSource&lt;Int, SomeItem&gt;() {
  
      override fun loadInitial(params: LoadInitialParams&lt;Int&gt;, callback: LoadInitialCallback&lt;Int, SomeItem&gt;) {
          // Simple load from API and notification of `callback`.
      }
  
      override fun loadAfter(params: LoadParams&lt;Int&gt;, callback: LoadCallback&lt;Int, SomeItem&gt;) {
          // Simple load from API and notification of `callback`.
      }
  
      override fun loadBefore(params: LoadParams&lt;Int&gt;, callback: LoadCallback&lt;Int, SomeItem&gt;) {
          // Simple load from API and notification of `callback`.
      }
  }
  </code></pre>
  
  <p>How would a concrete implementation of an in-memory cache (without Room and without invalidating the entire dataset) as referenced in the documentation look like?</p>