write

abstract suspend fun <R> write(block: MutableRealm.() -> R): R

Modify the underlying Realm file in a suspendable transaction on the default Realm Write Dispatcher.

The write transaction always represent the latest version of data in the Realm file, even if the calling Realm not yet represent this.

Write transactions automatically commit any changes made when the closure returns unless MutableRealm.cancelWrite was called.

Return

any value returned from the provided write block. If this is a RealmObject it is frozen before being returned.

See also

RealmConfiguration.writeDispatcher

Parameters

block

function that should be run within the context of a write transaction.