-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: mramotar <[email protected]>
- Loading branch information
1 parent
705539e
commit 0b901bc
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
paging/core/src/commonMain/kotlin/org/mobilenativefoundation/paging/core/Pager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.mobilenativefoundation.paging.core | ||
|
||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
/** | ||
* [Pager] is responsible for coordinating the paging process and providing access to the paging state and data. | ||
* This is the main entry point for the [org.mobilenativefoundation.paging] library. | ||
* | ||
* @param Id The type of the unique identifier for each item in the paged data. | ||
* @param K The type of the key used for paging. | ||
* @param P The type of the parameters associated with each page of data. | ||
* @param D The type of the data items. | ||
* @param E The type of errors that can occur during the paging process. | ||
* @param A The type of custom actions that can be dispatched to modify the paging state. | ||
*/ | ||
interface Pager<Id : Comparable<Id>, K : Any, P : Any, D : Any, E : Any, A : Any> { | ||
/** | ||
* The current paging state exposed as a [StateFlow]. | ||
* The paging state represents the current state of the paging data, including loaded pages, errors, and loading status. | ||
* Observers can collect this flow to react to changes in the paging state. | ||
*/ | ||
val state: StateFlow<PagingState<Id, K, P, D, E>> | ||
|
||
/** | ||
* Dispatches a user-initiated [PagingAction] to modify the paging state. | ||
* | ||
* User actions can be dispatched to trigger specific behaviors or modifications to the paging state. | ||
* The dispatched action will go through the configured [Middleware] chain and [Reducer] before updating the paging state. | ||
* After updating the state, the dispatched action will launch each configured post-reducer [Effect]. | ||
* | ||
* @param action The user-initiated [PagingAction] to dispatch. | ||
*/ | ||
fun dispatch(action: PagingAction.User<Id, K, P, D, E, A>) | ||
} | ||
|