-
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
505ea5f
commit 8762ec4
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
paging/core/src/commonMain/kotlin/org/mobilenativefoundation/paging/core/PagingData.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,49 @@ | ||
package org.mobilenativefoundation.paging.core | ||
|
||
|
||
/** | ||
* Represents paging data that can be either a single item or a collection of items. | ||
* | ||
* @param Id The type of the unique identifier for each item. | ||
* @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. | ||
*/ | ||
sealed interface PagingData<out Id : Any, out K : Any, out P : Any, out D : Any> { | ||
|
||
/** | ||
* Represents a single item of paging data. | ||
* | ||
* @param Id The type of the unique identifier for the item. | ||
* @param K The type of the key used for paging. | ||
* @param P The type of the parameters associated with the item. | ||
* @param D The type of the data item. | ||
* @property id The unique identifier of the item. | ||
* @property data The data item. | ||
*/ | ||
data class Single<Id : Any, K : Any, P : Any, D : Any>( | ||
val id: Id, | ||
val data: D | ||
) : PagingData<Id, K, P, D> | ||
|
||
/** | ||
* Represents a collection of paging data items. | ||
* | ||
* @param Id The type of the unique identifier for each item. | ||
* @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. | ||
* @property items The list of paging data items in the collection. | ||
* @property itemsBefore The number of items before the current collection, if known. | ||
* @property itemsAfter The number of items after the current collection, if known. | ||
* @property prevKey The paging key of the previous page of data. | ||
* @property nextKey The paging key of the next page of data, if available. | ||
*/ | ||
data class Collection<Id : Any, K : Any, P : Any, D : Any>( | ||
val items: List<Single<Id, K, P, D>>, | ||
val itemsBefore: Int?, | ||
val itemsAfter: Int?, | ||
val prevKey: PagingKey<K, P>, | ||
val nextKey: PagingKey<K, P>?, | ||
) : PagingData<Id, K, P, D> | ||
} |
14 changes: 14 additions & 0 deletions
14
paging/core/src/commonMain/kotlin/org/mobilenativefoundation/paging/core/PagingKey.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,14 @@ | ||
package org.mobilenativefoundation.paging.core | ||
|
||
/** | ||
* Represents a key used for paging along with its associated parameters. | ||
* | ||
* @param K The type of the key. | ||
* @param P The type of the parameters. | ||
* @property key The key value used for paging. | ||
* @property params The parameters associated with the key. | ||
*/ | ||
data class PagingKey<out K : Any, out P : Any>( | ||
val key: K, | ||
val params: P, | ||
) |