Is realm.all() block UI because it is not an async function?
Not likely, but it depends on the use case - e.g. in what context is that being used? Can you supply some code?
Yes, as @Jay says realm.all<T>()
is fast. It does not, as you may think, fetch all T
s from the realm immediately. It sets up a query semantically similar to realm.query<T>('TRUEPREDICATE')
and returns a RealmResults
object. This is lazy so you can iterate over it, or index into it, paying only for the io-ops needed.
Of course if you do something like realm.all<T>().map((t) => t.readAllPropsAndCreateNonRealmObject()).toList()
then you are explicitly asking to eagerly fetch every single property of every single T
in your database. Depending on the number of objects that may be expensive, so don’t do that.
@Th_Nga_Ninh I previously gave an example of how to efficiently work with the results of a query in combination with a flutter ListView
(in particular realm.all<T>()
) here: Realm Query Pagination · Issue #1058 · realm/realm-dart · GitHub if that is useful.
Thanks for your answer.
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.