Realm-js: How to implement pagination?

Created on 10 Dec 2015  路  1Comment  路  Source: realm/realm-js

Is there any recommended way to do pagination using realm js? For eg: I want to show the first 10 rows at page load and then load the next 25 based on certain user action(like pull to refresh).

Most helpful comment

If you're querying the realm with realm.objects(), then the "results" object you get back will retrieve the objects you need out of the realm as you access its indexed properties. Since it's not greedily retrieving all the objects out of the realm, you can comfortably just access the first 10 (or the next 25 after that) without worrying about a performance penalty for making a query that would return lots of objects.

In the future, would mind asking these questions on the mailing list so everyone can benefit from these responses, and so we can keep the issue tracker only for bugs and features. Thanks!

>All comments

If you're querying the realm with realm.objects(), then the "results" object you get back will retrieve the objects you need out of the realm as you access its indexed properties. Since it's not greedily retrieving all the objects out of the realm, you can comfortably just access the first 10 (or the next 25 after that) without worrying about a performance penalty for making a query that would return lots of objects.

In the future, would mind asking these questions on the mailing list so everyone can benefit from these responses, and so we can keep the issue tracker only for bugs and features. Thanks!

Was this page helpful?
0 / 5 - 0 ratings