Skip to content

Commit

Permalink
Merge pull request #10 from Sarquella/placeholders-compatibility
Browse files Browse the repository at this point in the history
Updated README.md for compatibility with Paging Library placeholders
  • Loading branch information
Sarquella authored Jun 15, 2020
2 parents 12e8eec + 7c10e01 commit f99fb27
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,32 @@ Alternatively, the `toLiveData` extension function can also be used:
val liveDataPagedList = mutableDataSourceFactory.toLiveData(pageSize)
```

---

**Placeholders [Optional]**

In order to be able to use placeholders in the Paging Library, it should be capable of computing the total number of items even before loading all of them. When applying the mutation function, this total count might change due to modifying the number of items per page.

In case the total number of items after mutating is already known, it can be specified when applying the mutating function to continue making use of the placeholders:

**Java**

```Java
... = DataSourceTransformation.mutateByPage(dataSourceFactory, totalCount, original -> {
//Mutate
});
```

**Kotlin**

```kotlin
... = dataSourceFactory.mutateByPage(totalCount) { original ->
//Mutate
}

```


## License
[LICENSE](https://github.com/Sarquella/MutableDataSource/blob/master/LICENSE)

Expand Down

0 comments on commit f99fb27

Please sign in to comment.