writeBlocking

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

Modify the underlying Realm file while blocking the calling thread until the transaction is done. Write transactions automatically commit any changes made when the closure returns unless MutableRealm.cancelWrite was called.

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

Return

any value returned from the provided write block.

Parameters

block

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

Throws

if invoked inside an existing transaction.