Created
July 16, 2021 11:20
-
-
Save cmelchior/a5739f4205d0b964ab508c3e8a9e247b to your computer and use it in GitHub Desktop.
Realm Kotlin 0.40 Release Blog Post - Suspendable Write
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
CoroutineScope(Dispatchers.Main).launch { | |
// Write automatically happens on a background dispatcher | |
val jane = realm.write { | |
val unmanaged = Person("Jane") | |
// Add unmanaged objects | |
copyToRealm(unmanaged) | |
} | |
// Objects returned from writes are automatically frozen | |
jane.isFrozen() // == true | |
// Access any property. | |
// All properties are still lazy-loaded. | |
jane.name // == "Jane" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment