React Native Realm database: How to return a promise from a write command?

I am using the Realm.io database in a React Native application. 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 a write operation for some reason takes more than a couple of milliseconds, how can I make sure that when I ask Bob for a dog, I will get an updated object?

Is there a way for a write operation to return a promise or something similar so that I can only execute the code after the write operation succeeds?

+4
source share
1 answer

. , #write, , , React Native. ,

- , .

+6

Source: https://habr.com/ru/post/1653725/


All Articles