我创建了一个函数来处理事务,然后我将它调用到多个地方。当我打开新事务时另一个事务尚未完成时,我崩溃了。
这是我的代码:
const RealmMakeTransaction = async (action) => {
try {
realm.GetInstance().beginTransaction();
let response = await action();
realm.GetInstance().commitTransaction();
return response;
} catch (e) {
realm.GetInstance().cancelTransaction();
}
};