https://github.com/chrynan/paginate

A Kotlin Multi-platform pagination repository abstraction library.

https://github.com/chrynan/paginate

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

kotlin kotlin-library kotlin-multi-platform kotlin-multiplatform kotlin-multiplatform-library pagination paging paging-library
Last synced: 9 months ago · JSON representation

Repository

A Kotlin Multi-platform pagination repository abstraction library.

Basic Info
  • Host: GitHub
  • Owner: chRyNaN
  • License: apache-2.0
  • Language: Kotlin
  • Default Branch: main
  • Homepage:
  • Size: 144 KB
Statistics
  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 4
Topics
kotlin kotlin-library kotlin-multi-platform kotlin-multiplatform kotlin-multiplatform-library pagination paging paging-library
Created over 5 years ago · Last pushed about 4 years ago
Metadata Files
Readme License

README.md

paginate

A Kotlin Multi-platform pagination repository abstraction library.
GitHub tag (latest by date)

Using the library

  • First, simply create a PaginateRepository implementation for your data object. The easiest way to create a PaginateRepository is to extend from BasePaginateSource.

```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.
GitHub tag (latest by date)

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

GitHub Events

Total
Last Year

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 20
  • Total Committers: 1
  • Avg Commits per committer: 20.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Chris c****n@s****m 20
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago