Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

using realm.executeTransaction() instead of realm.beginTransaction() and realm.commitTransaction() #2474

Open
simarsingh24 opened this issue May 17, 2018 · 1 comment

Comments

@simarsingh24
Copy link
Member

Expected Behaviour

Realm.executeTransaction() should be used as it automatically handles calling realm.cancelTransaction() in case an exception is thrown.

Would you like to work on the issue?

Yes

What I propose
This should be changed to

Realm realm = Realm.getDefaultInstance();
realm.beginTransaction(); 
realm.copyToRealm(_something_)
realm.commitTransaction();

this->

try(Realm realmInstance = Realm.getDefaultInstance()) {
    realmInstance.executeTransaction((realm) -> realm.insertOrUpdate(_something_));
}
@simarsingh24
Copy link
Member Author

simarsingh24 commented May 17, 2018

@iamareebjamal should I proceed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant