1

I have an issue with PagedList and custom DataSource where my data fetch returns as expected, but my ViewModel Observer (Fragment in this case) gets an empty PagedList in onChanged.

I’ve gone down a few StackOverflow rabbit holes on the this, there wasn’t much on the topic, but the bit that I found suggested that it was related to concurrency, and that fetches must be done synchronously. In my case, I’m using Autobahn Socket library which has its own read / write threads, but I do ensure the call and receive are done on a single thread Executor whIch I also tried setting as LivePagedListBuilder’s fetchExecutor.

The other interesting thing, is that when I swap out the network fetch in loadInitial with a local database fetch (not using Room), it works fine, which suggests my ViewModel/DataSource wiring is Ok. In this scenario, I’ve also tried delegating every step of the task to many different concurrency patterns and it works every time, which goes against what a lot of the StackOverflow answers suggest about it having to be synchronous.

Conti
  • 1,017
  • 1
  • 11
  • 15
  • For anyone still interested, I have a solution here: https://stackoverflow.com/a/58291387/3429021 – Conti Nov 10 '19 at 07:34

0 Answers0