Skip to content

Commit 4b7af8f

Browse files
authored
Merge pull request #9 from Sarquella/java-compatibility
Java compatibility
2 parents caef6c8 + 65542be commit 4b7af8f

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ dependencies {
2222

2323
1. Apply the mutating function
2424

25+
**Java** ([Java 8+](https://developer.android.com/studio/write/java8-support) required)
26+
27+
```java
28+
MutableDataSource.Factory<Key, Value> mutableDataSourceFactory = DataSourceTransformation.mutateByPage(dataSourceFactory, original -> {
29+
//Mutate
30+
});
31+
```
32+
33+
34+
**Kotlin**
35+
2536
```kotlin
2637
val mutableDataSourceFactory = dataSourceFactory.mutateByPage { original ->
2738
//Mutate

mutabledatasource/src/main/java/dev/sarquella/mutabledatasource/MutateByPage.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:JvmName("DataSourceTransformation")
2+
13
package dev.sarquella.mutabledatasource
24

35
import androidx.paging.DataSource
@@ -22,6 +24,7 @@ import androidx.paging.PositionalDataSource
2224
* @param function Function that runs on each loaded page, returning mutated items.
2325
* @return
2426
*/
27+
@JvmOverloads
2528
@Suppress("UNCHECKED_CAST")
2629
fun <Key, Original, Mutated> DataSource.Factory<Key, Original>.mutateByPage(
2730
totalCount: Int? = null,

0 commit comments

Comments
 (0)