https://github.com/chrynan/paginate
A Kotlin Multi-platform pagination repository abstraction library.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.8%) to scientific vocabulary
Keywords
Repository
A Kotlin Multi-platform pagination repository abstraction library.
Basic Info
Statistics
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 4
Topics
Metadata Files
README.md
paginate
A Kotlin Multi-platform pagination repository abstraction library.
Using the library
- First, simply create a
PaginateRepositoryimplementation for your data object. The easiest way to create aPaginateRepositoryis to extend fromBasePaginateSource.
```kotlin data class User( val id: String, val name: String, val created: DateTimeString )
class UserPaginateRepository @Inject constructor(private val api: UserApi) : BasePaginateSource
override suspend fun fetch(
count: Int,
key: String?,
direction: PageDirection,
currentPageCount: Int
): PagedResult<String, User> {
val users = if (direction == PageDirection.AFTER) {
api.loadUsers(after = key, count = count)
} else {
api.loadUsers(before = key, count = count)
}
val pageInfo = PageInfo(
index = currentPageCount,
hasPreviousPage = false,
hasNextPage = true,
firstKey = users.firstOrNull().id,
lastKey = users.firstOrNull().id
)
return PagedResult(
info = pageInfo,
items = users
)
}
} ```
- Then, use the created repository to load and paginate the data.
```kotlin // Subscribe to loaded pages, starting by loading the initial page. userPaginateRepository.loadPages() .onEach { // Do something with the emitted PagedResult objects } .catch { ... } .launchIn(this)
// Suspending function to load the next page. Will dispatch to the above Flow and return the PagedResult. val nextPage = userPaginateRepository.next()
// Suspending function to load the previous page. Will dispatch to the above Flow and return the PagedResult. val previousPage = userPaginateRepository.previous() ```
Building the library
The library is provided through repsy. Checkout
the releases page to get the latest version.
Repository
kotlin
repositories {
maven { url = uri("https://repo.repsy.io/mvn/chrynan/public") }
}
Dependency
kotlin
implementation("com.chrynan.paginate:paginate-core:$VERSION")
Documentation
Markdown Documentation is available in the docs folder.
License
``` Copyright 2020 chRyNaN
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```
Owner
- Name: Christopher
- Login: chRyNaN
- Kind: user
- Location: Austin, TX
- Company: Starry
- Website: https://chrynan.codes
- Repositories: 15
- Profile: https://github.com/chRyNaN
GitHub Events
Total
Last Year
Committers
Last synced: 11 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Chris | c****n@s****m | 20 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago