All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.ru.astrainteractive.klibs.paging.PagingCollector.kt Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package ru.astrainteractive.klibs.paging

import kotlinx.coroutines.flow.StateFlow
import ru.astrainteractive.klibs.paging.context.PageContext
import ru.astrainteractive.klibs.paging.state.PagingState

/**
 * This is a State Holder for your paging. Define it inside Repository or ViewModel
 */
interface PagingCollector {
    /**
     * Current state
     */
    val state: StateFlow>

    /**
     * Reset [state] to initial value and perform [cancelAndJoin]
     */
    suspend fun resetAndJoin()

    /**
     * Cancels current [loadNextPage] job
     */
    suspend fun cancelAndJoin()

    /**
     * Update current [state]
     */
    fun update(pagingState: (PagingState) -> PagingState)

    /**
     * Load next page if last page not reached
     */
    suspend fun loadNextPage()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy