title: Paging Library: How to reload portion of data on demand?
body: <p>I use <a href="https://developer.android.com/topic/libraries/architecture/paging.html" rel="noreferrer">Paging Library</a> to paginate my data set. What I'm trying to do is to refresh the <code>RecyclerView</code> after data in my database has been changed.</p>
  
  <p>I have this <code>LiveData</code>:</p>
  
  <pre><code>val listItems: LiveData&lt;PagedList&lt;Snapshot&gt;&gt; = object : LivePagedListProvider&lt;Long, Snapshot&gt;() {
          override fun createDataSource() = SnapshotsDataSource()
      }.create(null, PagedList.Config.Builder()
          .setPageSize(PAGE_SIZE)
          .setInitialLoadSizeHint(PAGE_SIZE)
          .setEnablePlaceholders(false)
          .build()
      )
  </code></pre>
  
  <p>And the <code>DataSource</code>:</p>
  
  <pre><code>class SnapshotsDataSource : KeyedDataSource&lt;Long, Snapshot&gt;(), KodeinGlobalAware {
  
      val db: FirebaseDb = instance()
  
      override fun getKey(item: Snapshot): Long = item.timestamp
  
      override fun loadInitial(pageSize: Int): List&lt;Snapshot&gt; {
          val result = db.getSnapshotsTail(pageSize)
          return result
      }
  
      override fun loadAfter(key: Long, pageSize: Int): List&lt;Snapshot&gt; {
          val result = db.getSnapshotsTail(key, pageSize)
          return result.subList(1, result.size)
      }
  
      override fun loadBefore(key: Long, pageSize: Int): List&lt;Snapshot&gt; {
          return emptyList()
      }
  
  }
  </code></pre>
  
  <p>The <code>Adapter</code> is straight forward, so i omit it here.</p>
  
  <p>I've tried to do this when database is modified:</p>
  
  <pre><code>fun reload(position) {
      listItems.value!!.loadAround(position)
  }
  </code></pre>
  
  <p>but it didn't help.</p>