GuavaDaoReturnTypeConverter


class GuavaDaoReturnTypeConverter


A DaoReturnTypeConverter that allows Room to return ListenableFuture<T> from @Dao functions.

Summary

Public constructors

Public functions

ListenableFuture<T>
@DaoReturnTypeConverter(operations = [OperationType.READOperationType.WRITE])
<T : Any?> convertAsync(
    database: RoomDatabase,
    inTransaction: Boolean,
    executeAndConvert: suspend () -> T
)

This convertAsync function will be called from Room generated code to convert a Room query result to the return type of this function.

Public constructors

GuavaDaoReturnTypeConverter

Added in 3.0.0-alpha06
GuavaDaoReturnTypeConverter()

Public functions

convertAsync

Added in 3.0.0-alpha06
@DaoReturnTypeConverter(operations = [OperationType.READOperationType.WRITE])
fun <T : Any?> convertAsync(
    database: RoomDatabase,
    inTransaction: Boolean,
    executeAndConvert: suspend () -> T
): ListenableFuture<T>

This convertAsync function will be called from Room generated code to convert a Room query result to the return type of this function.

This converter can be used for both OperationType.READ and OperationType.WRITE. Note that Room shortcut methods (@Insert, @Update, @Delete) are always treated as OperationType.WRITE.

Parameters
database: RoomDatabase

RoomDatabase instance

inTransaction: Boolean

True if the DAO is to be executed in a database transaction

executeAndConvert: suspend () -> T

A suspend lambda function that invokes the part of the generated code that executes the query.