我在React Native应用程序中使用Realm.io数据库.我有一个简单的写命令: Realm.write(() = { Realm.create('Dog', { name: 'Bob'}, true); }); //Few lines below, make a query for the Bob the dog. 如果由于某种原因写入操
Realm.write(() => { Realm.create('Dog', { name: 'Bob'}, true); }); //Few lines below, make a query for the Bob the dog.
如果由于某种原因写入操作花费的时间超过几毫秒,我怎样才能确保当我查询Bob的狗时,我会得到更新的对象?
有没有办法让write操作返回一个promise或者simillar,所以我可以确保只在写操作成功后执行代码?
领域是同步的. All callbacks handed to #write are blocking,但这并不是特别重要,因为它针对React Native进行了优化.仍然, the docs sayWrite transactions incur non-negligible overhead – you should architect your code to minimize the number of write transactions.