I am using Realm.io database in a React Native app. I have a simple write command:
Realm.write(() => {
Realm.create('Dog', { name: 'Bob'}, true);
});
//Few lines below, make a query for the Bob the dog.
If the write operation for some reason takes more then couple of milliseconds, how can I make sure that when I query for Bob the dog, I will get the updated object?
Is there a way for the write operation to return a promise or something simillar so I can be sure to execute code only after the write operation succeeded?
Realm is synchronous. All callbacks handed to #write are blocking, but that's not such a big deal as it is optimized for React Native. Still, the docs say
Write transactions incur non-negligible overhead - you should architect your code to minimize the number of write transactions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With