I have a question about Realm and Xamarin.Forms. I’m investigating the efficiency and speed of Realm database on Xamarin.Forms platform. The results are pretty amazing. But I have an issue with Realm query results and list view binding.
To stress test the scenario I’ve made a database which contains 20.000 lets say products. The code is very simple, I have IEnumerable in my view model and I set it to Realm.All(); Everything works great, products are loaded, but on lower end Android devices particularly the scrolling is horrendously choppy. I see a little bit of choppiness also on iPhone 5s. All over the places, even in documentation they say that because of lazy loading nature of Realm you don’t need to implement pagination, but in case where you need UI support you can simply “read” a subset of IQueryable.
I couldn’t find any example where you would “read” the data in background thread and pass it back to UI thread. In our example it would make sense to load products for instance 200 at a time.
To summarize, there are 2 questions that I need to answer to be able to implement lazy loading
- How to read a chunk from IQueryable?
- How to read that chunk in a background thread, this is particularly interesting cause in Realm you are not allowed to pass objects between threads.