• Stars
    star
    542
  • Rank 81,982 (Top 2 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library that packages AndroidX Paging for Kotlin/Multiplatform.

Multiplatform Paging

A library that packages AndroidX Paging for Kotlin/Multiplatform.

Introduction

As with AndroidX Paging, the primary modules of Multiplatform Paging are:

Unlike AndroidX Paging that makes paging-common JVM-specific and paging-runtime Android-specific, Multiplatform Paging makes paging-common multiplatform and provides paging-runtime-uikit, a UIKit-specific runtime for iOS. Therefore, pagination logic between Android and iOS can be shared, and the provided UI components can be used to render the paged items on Android and iOS.

Usage

❗Looking for a multiplatform version of paging-compose? Or support for version 3.2.0-alpha05 of AndroidX Paging instead of 3.1.1? Then check out this README instead!

For a holistic view of Multiplatform Paging, check out the GitHub Repository Search sample project, where there's an Android and iOS app, along with shared pagination logic.

paging-common

The API of paging-common in Multiplatform Paging is identical to that of paging-common in AndroidX Paging (with the exception that: the namespace has changed from androidx.paging to app.cash.paging; there are some minor API discrepancies due to limitations in the Kotlin compiler). Therefore, to see how to use paging-common, consult the official documentation of AndroidX Paging.

JVM

app.cash.paging:paging-common on the JVM delegates to androidx.paging:paging-common via type aliases. To understand what this means in practice, see the section Interoperability with AndroidX Paging.

iOS

app.cash.paging:paging-common on iOS delegates to our fork of AndroidX Paging.

iOS only includes the Paging 3 APIs from AndroidX Paging. We don't plan on offering Paging 2 support for iOS, though you can continue to use Paging 2 on the JVM.

paging-runtime for Android

See the Interoperability with AndroidX Paging section below.

paging-runtime-uikit for iOS

The PagingCollectionViewController allows a PagingData to be rendered via a UICollectionView. The PagingCollectionViewController mimics the UICollectionViewController, providing: the cell count; and item retrieval via IndexPath.

Here's an example in Swift:

final class FooViewController: UICollectionViewController {

  private let delegate = Paging_runtime_uikitPagingCollectionViewController<Foo>()

  private let presenter = …

  required init(coder: NSCoder) {
    super.init(coder: coder)!
    presenter.pagingDatas
      .sink { pagingData in
        self.delegate.submitData(pagingData: pagingData, completionHandler: …)
      }
  }

  override func collectionView(
    _ collectionView: UICollectionView,
    numberOfItemsInSection section: Int
  ) -> Int {
    return Int(delegate.collectionView(collectionView: collectionView, numberOfItemsInSection: Int64(section)))
  }

  override func collectionView(
    _ collectionView: UICollectionView,
    cellForItemAt indexPath: IndexPath
  ) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FooCell", for: indexPath) as! FooCell

    let item = delegate.getItem(position: Int32(indexPath.row))!
    // …

    return cell
  }
}

Interoperability with AndroidX Paging

As app.cash.paging:paging-common on the JVM type aliases to androidx.paging:paging-common, some useful side effects occur:

  • The implementation of app.cash.paging:paging-common on the JVM is identical to androidx.paging:paging-common. This means that it is impossible for there to be a behavioral discrepancy when using app.cash.paging:paging-common on the JVM.
  • All libraries that depend on androidx.paging:paging-common can continue to be used on the JVM (e.g., androidx.paging:paging-runtime, androidx.paging:paging-compose, androidx.paging:paging-rxjava3). This is why there aren't additional paging-runtime artifacts to support Android's UI toolkit, as you can instead depend on the official AndroidX artifact.
  • If you're already using AndroidX Paging, you don't need to refactor your Android code to use Multiplatform Paging. The use of Multiplatform Paging is only necessary if you wish to share pagination logic in common code and/or paginate on iOS.

Releases

The versioning scheme is of the form X-Y where:

  • X is the AndroidX Paging version that is being tracked.
  • Y is the Multiplatform Paging version.

For example, if AndroidX Paging is on 3.1.1 and Multiplatform Paging is on 0.3.1, the artifact for a release of paging-common will be app.cash.paging:paging-common:3.1.1-0.3.1.

paging-common for common

implementation("app.cash.paging:paging-common:3.1.1-0.3.1")

paging-runtime-uikit for iOS

implementation("app.cash.paging:paging-runtime-uikit:3.1.1-0.3.1")

Android

Use the official AndroidX Paging dependencies.

implementation("androidx.paging:paging-runtime:3.1.1")
implementation("androidx.paging:paging-compose:1.0.0-alpha17")
implementation("androidx.paging:paging-rxjava3:3.1.1")
// etc.

License

Copyright 2022 Block, Inc.

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.

More Repositories

1

sqldelight

SQLDelight - Generates typesafe Kotlin APIs from SQL
Kotlin
6,146
star
2

turbine

A testing library for kotlinx.coroutines Flow
Kotlin
2,472
star
3

paparazzi

Render your Android screens without a physical device or emulator
Kotlin
2,284
star
4

zipline

Run Kotlin/JS libraries in Kotlin/JVM and Kotlin/Native programs
C
2,053
star
5

molecule

Build a StateFlow stream using Jetpack Compose
Kotlin
1,864
star
6

redwood

Multiplatform reactive UI for Android, iOS, and web using Kotlin and Jetpack Compose
Kotlin
1,649
star
7

contour

Layouts with lambdas 😎
Kotlin
1,531
star
8

InflationInject

Constructor-inject views during XML layout inflation
Kotlin
904
star
9

licensee

Gradle plugin which validates the licenses of your dependency graph match what you expect
Kotlin
626
star
10

pranadb

Go
613
star
11

hermit

🐚 Hermit manages isolated, self-bootstrapping sets of tools in software projects.
Go
596
star
12

AccessibilitySnapshot

Easy regression testing for iOS accessibility
Swift
550
star
13

exhaustive

An annotation and Kotlin compiler plugin for enforcing a when statement is exhaustive
Kotlin
463
star
14

misk

Microservice Kontainer
Kotlin
402
star
15

copper

A content provider wrapper for reactive queries
Kotlin
301
star
16

barber

Barber πŸ’ˆ A type safe Kotlin JVM library for building up localized, fillable, themed documents using Mustache templating
Kotlin
166
star
17

paraphrase

A Gradle plugin that generates type-safe formatters for Android string resources in the ICU message format.
Kotlin
163
star
18

stagehand

Modern, type-safe API for building animations on iOS
Swift
132
star
19

hermit-packages

Hermit manages isolated, self-bootstrapping sets of tools in software projects.
HCL
120
star
20

quiver

Quiver is a collection of extension methods and handy functions to make the wonderful functional programming Kotlin library, Arrow, even better.
Kotlin
116
star
21

spirit

Online Schema Change Tool for MySQL 8.0+
Go
104
star
22

pivit

Go
89
star
23

tempest

Typesafe DynamoDB for Kotlin and Java.
Kotlin
83
star
24

better-dynamic-features

Making dynamic feature modules better
Kotlin
80
star
25

misk-web

Micro-Frontends React + Redux + Typescript Framework
TypeScript
64
star
26

blip

Sublime MySQL monitoring
Go
62
star
27

logquacious

Logquacious (lq) is a fast and simple log viewer.
TypeScript
59
star
28

wisp

Wisp is a collection of kotlin modules providing various features and utilities, including config, logging, feature flags and more.
Kotlin
57
star
29

certifikit

Kotlin Certificate processing library.
Kotlin
40
star
30

cash-app-pay-android-sdk

Cash Android PayKit SDK for merchant integrations with Cash App Pay
Kotlin
32
star
31

backfila

Service that manages backfill state, calling into other services to do batched work
Kotlin
31
star
32

nostrino

A Kotlin SDK for Nostr
Kotlin
28
star
33

cloner

Go
28
star
34

cash-app-pay-ios-sdk

Swift
24
star
35

transflect

Kubernetes operator using Istio to set up Envoy's gRPC-JSON transcoding.
Go
24
star
36

kfsm

Finite state machinery in Kotlin
Kotlin
22
star
37

cmmc

K8S ConfigMap Merging Controller
Go
21
star
38

yet-another-aws-exporter

A Prometheus metrics exporter for AWS that fills in gaps CloudWatch doesn't cover
Go
17
star
39

protosync

ProtoSync synchronises remote .proto files to a local directory
Go
15
star
40

cash-pay-pay-sdk-android-sample-app

Cash App Pay Kit SDK Sample app for Android.
Kotlin
15
star
41

trifle

Security functionality for interoperability/interaction with core services.
Swift
12
star
42

jooq-encryption

Kotlin
11
star
43

kfactories

Set of factories and utils to create effective and lightweight property-based testing strategies.
Kotlin
10
star
44

AardvarkReveal

Generate and attach a Reveal file to your Aardvark bug reports
Swift
10
star
45

ln-invoice

Parse lightning network payment requests (invoices) in Kotlin.
Kotlin
10
star
46

hermit-ij-plugin

Kotlin
9
star
47

kotlin-editor

Kotlin
8
star
48

cash-app-pay-sdk-ios-sample-app

Swift
8
star
49

awsu

su for aws roles
Go
8
star
50

AardvarkCrashReport

AardvarkCrashReport makes it easy to provide high quality data about crashes in your bug reports
Swift
7
star
51

activate-hermit

Github Action to activate a Hermit environment.
Shell
7
star
52

knit

Safety features for Swinject
Swift
7
star
53

csop

Go
6
star
54

check-signature-action

Shell
5
star
55

kruit

TypeScript
4
star
56

hermit-build

Relocatable/static builds for Hermit packages
Makefile
3
star
57

chronicler

Kotlin
2
star
58

s3-copy-gradle-plugin

1
star
59

.github

1
star
60

hermit-package-version

Shell
1
star
61

cash-app-pay-sandbox-releases

1
star