Announcing Multiplatform Paging

Writing code that consumes paginated data is like opening Pandora’s box. It involves a bunch of hard problems which look easy upon initial inspection. AndroidX Paging from Android™ is awesome as it solves many of these hard problems, like in-memory caching, request deduplication, and support for page jumping.

At Cash App, we want to share pagination logic across platforms. Unfortunately, AndroidX Paging only supports Android, but we want to use it on other platforms too.

Introducing Multiplatform Paging

Multiplatform Paging is a library that packages AndroidX Paging for Kotlin/Multiplatform. It’s built to be a drop-in-replacement for AndroidX Paging, so extracting out shared pagination logic couldn’t be easier.

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 iOS as an additional target to paging-runtime. 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.

Using Multiplatform Paging has a number of advantages:

  1. On the JVM, Multiplatform Paging is binary compatible with AndroidX Paging. Except for some additional type aliases, the implementation code is actually identical!
  2. All libraries that depend on AndroidX Paging can continue to be used on the JVM.
  3. If you already use AndroidX Paging, there’s no need to learn yet another API. If you don’t already use AndroidX Paging, it’s well documented.

Currently, Multiplatform Paging only supports Android and iOS. Support for other platforms will be added on a per-need basis. We also plan to track AndroidX Paging releases as needed.

Check out the README to get started!

Note: Android is a trademark of Google LLC.