mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-16 15:32:50 +01:00
3fd9e021fa
* Use custom QueryPagingSource - Adds placeholder to make the list jump around less - Fixes issue where SQLDelight QueryPagingSource would throw IndexOutOfBounds * Review Changes
38 lines
1.1 KiB
Kotlin
38 lines
1.1 KiB
Kotlin
package eu.kanade.data
|
|
|
|
import androidx.paging.PagingSource
|
|
import com.squareup.sqldelight.Query
|
|
import eu.kanade.tachiyomi.Database
|
|
import kotlinx.coroutines.flow.Flow
|
|
|
|
interface DatabaseHandler {
|
|
|
|
suspend fun <T> await(inTransaction: Boolean = false, block: suspend Database.() -> T): T
|
|
|
|
suspend fun <T : Any> awaitList(
|
|
inTransaction: Boolean = false,
|
|
block: suspend Database.() -> Query<T>,
|
|
): List<T>
|
|
|
|
suspend fun <T : Any> awaitOne(
|
|
inTransaction: Boolean = false,
|
|
block: suspend Database.() -> Query<T>,
|
|
): T
|
|
|
|
suspend fun <T : Any> awaitOneOrNull(
|
|
inTransaction: Boolean = false,
|
|
block: suspend Database.() -> Query<T>,
|
|
): T?
|
|
|
|
fun <T : Any> subscribeToList(block: Database.() -> Query<T>): Flow<List<T>>
|
|
|
|
fun <T : Any> subscribeToOne(block: Database.() -> Query<T>): Flow<T>
|
|
|
|
fun <T : Any> subscribeToOneOrNull(block: Database.() -> Query<T>): Flow<T?>
|
|
|
|
fun <T : Any> subscribeToPagingSource(
|
|
countQuery: Database.() -> Query<Long>,
|
|
queryProvider: Database.(Long, Long) -> Query<T>,
|
|
): PagingSource<Long, T>
|
|
}
|