Request: update example app to asynchronously open realm
See original GitHub issueThe current example initialises the realm in a seperate file (module) which is then exported and imported into the other files:
//realm.js
export default new Realm({schema: [Todo, TodoList]});
However, the docs state:
This is typically not recommended as it blocks and could potentially be a time consuming operation, especially if there are migrations to run or if the realm is synchronized and you don’t want to risk modifying data before it’s been completely downloaded. https://realm.io/docs/javascript/latest/#synchronously-opening-realms
Can the example app please be updated to show how to open the realm (with Realm.open) in a seperate file (module) which is then imported into the other components?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:24 (10 by maintainers)
Top Results From Across the Web
Asynchronous API - Java SDK — Realm - MongoDB
The Java SDK lets you access network and disk resources in two ways: synchronously and asynchronously. While synchronous, or "sync", requests block ...
Read more >How to use realm with async fetch request? - Stack Overflow
Finally ,I use realm like this: let realm = new Realm({schema:[JOB_SCHEMA.jobTrack],encryptionKey:getRealmKey()}); let objects ...
Read more >The things I've learned using Realm | by Gabor Varadi - Medium
Observable async queries, change listeners, and lazy loading So in practice, setting up a Realm query on the UI thread involves both defining...
Read more >Build offline-first mobile application using MongoDB Realm ...
While these applications might make network requests when available, ... "Note: demo app supports offline sync, Open & Close a Local Realm ......
Read more >4 Introduction to Developing Asynchronous Web Services
However, because request processing can be delayed, it is often useful for the client application to continue its work and handle the response...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@MrHubble we’re working on an example app for React Native, until it’s merged you can have a look at the branch for the PR: https://github.com/realm/my-first-realm-app/tree/eric-rn/react-native/QueryBasedSync/ToDo
Here we’re using
new Realm(config)to open a Realm instance when the user authenticates. Then we pass the realm instance to the apps router (in our casereact-native-router-flux) to change into a “logged in” scene: https://github.com/realm/my-first-realm-app/blob/eric-rn/react-native/QueryBasedSync/ToDo/src/components/LoginForm.js#L61-L68I hope this gives an idea on how this can be accomplished and I hope that we’ll soon be able to get better React Native examples published.
Every
new RealmorRealm.openmust be paired withclose. As React Native runs as 32 bit, you can easily run into memory issues (600-700 MB Realm files). It can be a good idea to compact the Realm when your app is launching (shouldCompactOnLaunch- https://realm.io/docs/javascript/2.20.0/api/Realm.html#~Configuration).