title: Android Paging Library LiveData<PagedList<T>> is triggered before the end of the api call
body: <p>It's been 2 days I'm trying to learn how to use the new Paging Library with the Kotlin Language (first time too)</p>
  
  <p>So I've read many guide / tutorial and Github repo (<a href="https://github.com/STAR-ZERO/paging-retrofit-sample" rel="nofollow noreferrer">https://github.com/STAR-ZERO/paging-retrofit-sample</a>) for implementing this paging library and basically my trouble is my <code>LiveData&lt;PagedList&lt;Discover&gt;&gt;</code> inside my <code>ViewModel</code> is trigger before my api call is ending and I don't know why and I feel the call <code>callback.onResult(it?.results.orEmpty(), null, 2)</code> doesn't do anything</p>
  
  <p>I'm using this version <code>android.arch.paging:runtime:1.0.1</code>
  You can find the repo of my project here : <a href="https://github.com/florian-do/TMDB" rel="nofollow noreferrer">https://github.com/florian-do/TMDB</a></p>
  
  <p><code>logcat :</code></p>
  
  <pre><code>D/DataSourceFactory: : create()
  D/SequentialDataSource: loadInitial:
  D/Interceptor: https://api.themoviedb.org/3/discover/movie?api_key=??
  D/MainFragment: : observe 0
  D/SequentialDataSource: response code -&gt; 200
  D/SequentialDataSource: list size: 20
  </code></pre>
  
  <p>Here there is my code :</p>
  
  <p><code>Fragment.kt</code></p>
  
  <pre><code>    val adapter = DiscoverAdapter(context!!, diffCallBack)
      binding.rvFeed.layoutManager = GridLayoutManager(context, 3)
      binding.rvFeed.setHasFixedSize(true)
      binding.rvFeed.adapter = adapter
  
      viewModel.data.observe(this, Observer {
          Log.d(TAG, ": observe "+it?.size)
      })
  </code></pre>
  
  <p><code>MainViewModel.kt</code></p>
  
  <pre><code>class MainViewModel : ViewModel() {
  
      var amount = ObservableField&lt;String&gt;()
      val data : LiveData&lt;PagedList&lt;Discover&gt;&gt;
  
      init {
          val config = PagedList.Config.Builder()
                  .setPageSize(20)
                  .setEnablePlaceholders(false)
                  .build()
  
          val api : DiscoverService = App.retrofit.create(DiscoverService::class.java)
          val dataSourceFactory = DataSourceFactory(api)
  
          data = LivePagedListBuilder(dataSourceFactory, config).build()
      }
  }
  </code></pre>
  
  <p><code>DataSourceFactory.kt</code></p>
  
  <pre><code>class DataSourceFactory(api: DiscoverService) : DataSource.Factory&lt;Int, Discover&gt;() {
      val source = SequentialDataSource(api)
  
      override fun create(): DataSource&lt;Int, Discover&gt; {
          return source
      }
  }
  </code></pre>
  
  <p><code>SequentialDataSource.kt</code></p>
  
  <pre><code>class SequentialDataSource(val api : DiscoverService) : PageKeyedDataSource&lt;Int, Discover&gt;() {
  
      private val TAG = "SequentialDataSource"
  
      override fun loadInitial(params: LoadInitialParams&lt;Int&gt;, callback: LoadInitialCallback&lt;Int, Discover&gt;) {
          Log.d(TAG, "loadInitial: ")
          api.getDiscover(TMDBClient.API_KEY).enqueue(object : Callback&lt;DiscoverReponse&gt; {
              override fun onFailure(call: Call&lt;DiscoverReponse&gt;, t: Throwable) {
                  Log.d(TAG, ": FAIL")
              }
  
              override fun onResponse(call: Call&lt;DiscoverReponse&gt;, response: Response&lt;DiscoverReponse&gt;) {
                  Log.d(TAG, ": response code -&gt; "+response.code())
                  val it = response.body();
                  Log.d(TAG, "list size: "+it?.results?.size)
  
                  response.body()?.let {
                      callback.onResult(it.results, null, 2)
                  }
              }
  
          })
  
      }
  
      override fun loadAfter(params: LoadParams&lt;Int&gt;, callback: LoadCallback&lt;Int, Discover&gt;) {
          Log.d(TAG, "loadAfter: "+params.key)
  
      }
  
      override fun loadBefore(params: LoadParams&lt;Int&gt;, callback: LoadCallback&lt;Int, Discover&gt;) {
          Log.d(TAG, "loadBefore: "+params.key)
      }
  }
  </code></pre>