Created
April 7, 2018 19:32
-
-
Save AOrobator/ef1260c541ab91553f935ce2af549c2e to your computer and use it in GitHub Desktop.
RealmTransaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun realmTransaction(onError: (Throwable) -> Unit = {}, transaction: (Realm) -> Unit) { | |
val realm = Realm.getDefaultInstance() | |
try { | |
realm.executeTransactionAsync { transaction(it) } | |
} catch (e: Exception) { | |
onError(e) | |
} | |
realm.close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment