You can query a realm to find objects based on their type and the values of their properties. Objects and queries always reflect the latest state of an object and emit notifications that can update your app whenever data changes.
For code examples that show how to read and filter Realm objects with the React Native SDK, see Read Operations.
Data in Realm is live, which means that an object always reflects its most recent saved state and read operations never block. Objects automatically update in response to changes, so you can see up-to-date data in your application without running a new query.
Some queries only need to access a subset of all objects that match the query. Realm's lazy-loaded collections only fetch objects when you actually access them, so you do not need any special mechanism to limit query results.
For example, if you only want to find 10 matching objects at a time (such as in a paged product catalog) you can just access ten elements of the results collection. To advance to the next page, access the next ten elements of the results collection starting at the index immediately following the last element of the previous page.
Realm objects and collections always reflect the latest state of your data when you read them. Realm emits a change notification whenever the state of your data changes, which lets you reactively update your app in response to committed write transaction.
You can register three types of notification listeners:
- A realm listener fires whenever any object in a realm changes.
- A collection listener fires whenever a specific query matches a new set of objects or when any matched object changes.
- An object listener fires whenever a specific object is deleted or has one or more properties modified.
For code examples that show how to define, register, and clean up change notification listeners with the React Native SDK, see React to Changes.