ListenableFuturePagingSourceDaoReturnTypeConverter


class ListenableFuturePagingSourceDaoReturnTypeConverter


A DaoReturnTypeConverter that allows Room to return Guava-based ListenableFuturePagingSource types from @Dao functions.

You can register this converter via annotating a androidx.room3.Database or androidx.room3.Dao using the annotation androidx.room3.DaoReturnTypeConverters:

@DaoReturnTypeConverters(
ListenableFuturePagingSourceDaoReturnTypeConverter::class
)

Summary

Public functions

ListenableFuturePagingSource<Int, T>
@DaoReturnTypeConverter(operations = [OperationType.READ])
<T : Any> convert(
    database: RoomDatabase,
    tableNames: Array<String>,
    roomRawQuery: RoomRawQuery,
    executeAndConvert: suspend (RoomRawQuery) -> List<T>
)

Converts a Room query into a ListenableFuturePagingSource.

Public constructors

ListenableFuturePagingSourceDaoReturnTypeConverter

Added in 3.0.0-alpha04
ListenableFuturePagingSourceDaoReturnTypeConverter()

Public functions

convert

@DaoReturnTypeConverter(operations = [OperationType.READ])
fun <T : Any> convert(
    database: RoomDatabase,
    tableNames: Array<String>,
    roomRawQuery: RoomRawQuery,
    executeAndConvert: suspend (RoomRawQuery) -> List<T>
): ListenableFuturePagingSource<Int, T>

Converts a Room query into a ListenableFuturePagingSource.

This converter can be used for both OperationType.READ only.

Parameters
database: RoomDatabase

RoomDatabase instance.

tableNames: Array<String>

List of names of the tables of the RoomDatabase to observe for invalidation.

roomRawQuery: RoomRawQuery

The initial RoomRawQuery to be executed.

executeAndConvert: suspend (RoomRawQuery) -> List<T>

A suspend lambda function that invokes the part of the generated code that executes the query. This function takes a RoomRawQuery (modified for limit/offset) and returns a List of T.

Returns
ListenableFuturePagingSource<Int, T>

A ListenableFuturePagingSource that emits pages of type T.