Skip to content

Instantly share code, notes, and snippets.

@AOrobator
Created April 7, 2018 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AOrobator/ef1260c541ab91553f935ce2af549c2e to your computer and use it in GitHub Desktop.
Save AOrobator/ef1260c541ab91553f935ce2af549c2e to your computer and use it in GitHub Desktop.
RealmTransaction
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