{"id":13407095,"url":"https://github.com/icerockdev/moko-paging","last_synced_at":"2025-08-11T07:38:10.040Z","repository":{"id":38465975,"uuid":"241032010","full_name":"icerockdev/moko-paging","owner":"icerockdev","description":"Pagination logic in common code for mobile (android \u0026 ios) Kotlin Multiplatform development","archived":false,"fork":false,"pushed_at":"2022-09-12T10:06:35.000Z","size":218,"stargazers_count":58,"open_issues_count":7,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-07-31T20:26:43.265Z","etag":null,"topics":["android","ios","kotlin","kotlin-multiplatform","kotlin-native","moko"],"latest_commit_sha":null,"homepage":"https://moko.icerock.dev/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/icerockdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-17T06:05:10.000Z","updated_at":"2024-06-23T16:49:32.000Z","dependencies_parsed_at":"2022-09-26T22:01:49.526Z","dependency_job_id":null,"html_url":"https://github.com/icerockdev/moko-paging","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icerockdev%2Fmoko-paging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icerockdev%2Fmoko-paging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icerockdev%2Fmoko-paging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icerockdev%2Fmoko-paging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icerockdev","download_url":"https://codeload.github.com/icerockdev/moko-paging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243569324,"owners_count":20312402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","ios","kotlin","kotlin-multiplatform","kotlin-native","moko"],"created_at":"2024-07-30T20:00:19.704Z","updated_at":"2025-03-14T11:31:02.614Z","avatar_url":"https://github.com/icerockdev.png","language":"Kotlin","readme":"![moko-paging](img/logo.png)  \n[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://img.shields.io/maven-central/v/dev.icerock.moko/paging) ](https://repo1.maven.org/maven2/dev/icerock/moko/paging) ![kotlin-version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=dev.icerock.moko\u0026name=paging)\n\n# Mobile Kotlin paging\nThis is a Kotlin MultiPlatform library that contains pagination logic for kotlin multiplatform\n\n## Table of Contents\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Samples](#samples)\n- [Set Up Locally](#set-up-locally)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n- **Pagination** implements pagination logic for the data from abstract `PagedListDataSource`.\n- Managing a data loading process using **Pagination** asynchronous functions: `loadFirstPage`, `loadNextPage`,\n`refresh` or their duplicates with `suspend` modifier.\n- Observing states of **Pagination** using `LiveData` from **moko-mvvm**.\n\n## Requirements\n- Gradle version 6.8+\n- Android API 16+\n- iOS version 11.0+\n\n## Installation\nroot build.gradle  \n```groovy\nallprojects {\n    repositories {\n        mavenCentral()\n    }\n}\n```\n\nproject build.gradle\n```groovy\ndependencies {\n    commonMainApi(\"dev.icerock.moko:paging:0.7.1\")\n}\n```\n\n## Usage\n\nYou can use **Pagination** in `commonMain` sourceset.\n\n**Pagination** creation:\n\n```kotlin\nval pagination: Pagination\u003cInt\u003e = Pagination(\n        parentScope = coroutineScope,\n        dataSource = LambdaPagedListDataSource { currentList -\u003e\n            extrenalRepository.loadPage(currentList) \n        },\n        comparator = Comparator { a: Int, b: Int -\u003e\n            a - b\n        },\n        nextPageListener = { result: Result\u003cList\u003cInt\u003e\u003e -\u003e\n            if (result.isSuccess) {\n                println(\"Next page successful loaded\")\n            } else {\n                println(\"Next page loading failed\")\n            }\n        },\n        refreshListener = { result: Result\u003cList\u003cInt\u003e\u003e -\u003e\n            if (result.isSuccess) {\n                println(\"Refresh successful\")\n            } else {\n                println(\"Refresh failed\")\n            }\n        },\n        initValue = listOf(1, 2, 3)\n    )\n```\n\nManaging data loading:\n\n```kotlin\n// Loading first page\npagination.loadFirstPage()\n\n// Loading next page\npagination.loadNextPage()\n\n// Refreshing pagnation\npagination.refresh()\n\n// Setting new list\npagination.setData(itemsList)\n```\n\nObserving **Pagination** states:\n\n```kotlin\n// Observing the state of the pagination\npagination.state.addObserver { state: ResourceState\u003cList\u003cItemClass\u003e, Throwable\u003e -\u003e \n    // ...\n}\n\n// Observing the next page loading process\npagination.nextPageLoading.addObserver { isLoading: Boolean -\u003e \n    // ...\n}\n\n// Observing the refresh process\npagination.refreshLoading.addObserver { isRefreshing: Boolean -\u003e \n    // ...    \n}\n```\n\n## Samples\nPlease see more examples in the [sample directory](sample).\n\n## Set Up Locally \n- The [paging directory](paging) contains the `paging` library;\n- The [sample directory](sample) contains sample apps for Android and iOS; plus the mpp-library connected to the apps.\n\n## Contributing\nAll development (both new features and bug fixes) is performed in the `develop` branch. This way `master` always contains the sources of the most recently released version. Please send PRs with bug fixes to the `develop` branch. Documentation fixes in the markdown files are an exception to this rule. They are updated directly in `master`.\n\nThe `develop` branch is pushed to `master` on release.\n\nFor more details on contributing please see the [contributing guide](CONTRIBUTING.md).\n\n## License\n        \n    Copyright 2020 IceRock MAG Inc.\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n       http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","funding_links":[],"categories":["Libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficerockdev%2Fmoko-paging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficerockdev%2Fmoko-paging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficerockdev%2Fmoko-paging/lists"}