RoomDatabaseKt

public final class RoomDatabaseKt


Summary

Public methods

static final @NonNull R
<R extends Object> RoomDatabaseKt.withTransaction(
    @NonNull RoomDatabase receiver,
    @NonNull SuspendFunction0<@NonNull R> block
)

Calls the specified suspending block in a database transaction.

Public methods

RoomDatabaseKt.withTransaction

@NonNull
public static final R <R extends Object> RoomDatabaseKt.withTransaction(
    @NonNull RoomDatabase receiver,
    @NonNull SuspendFunction0<@NonNull R> block
)

Calls the specified suspending block in a database transaction. The transaction will be marked as successful unless an exception is thrown in the suspending block or the coroutine is cancelled.

Room will only perform at most one transaction at a time, additional transactions are queued and executed on a first come, first serve order.

Performing blocking database operations is not permitted in a coroutine scope other than the one received by the suspending block. It is recommended that all Dao function invoked within the block be suspending functions.

The dispatcher used to execute the given block will utilize threads from Room's query executor.