What is the correct way to make realm.write() async so that can use await within?

Can I use await within realm.write()? I am using the JS SDK. If so, is below the correct/best way? Or is there a “best practice” for doing below?

Basically I am just turning this: realm.write(() => {} into this: realm.write(async () => {} adding the async keyword.

realm.write(async () => {
    let realmObject = await myFunction();
    //Do some other stuff
1 Like