Skip to content

Commit f99fb27

Browse files
authored
Merge pull request #10 from Sarquella/placeholders-compatibility
Updated README.md for compatibility with Paging Library placeholders
2 parents 12e8eec + 7c10e01 commit f99fb27

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,32 @@ Alternatively, the `toLiveData` extension function can also be used:
5656
val liveDataPagedList = mutableDataSourceFactory.toLiveData(pageSize)
5757
```
5858

59+
---
60+
61+
**Placeholders [Optional]**
62+
63+
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.
64+
65+
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:
66+
67+
**Java**
68+
69+
```Java
70+
... = DataSourceTransformation.mutateByPage(dataSourceFactory, totalCount, original -> {
71+
//Mutate
72+
});
73+
```
74+
75+
**Kotlin**
76+
77+
```kotlin
78+
... = dataSourceFactory.mutateByPage(totalCount) { original ->
79+
//Mutate
80+
}
81+
82+
```
83+
84+
5985
## License
6086
[LICENSE](https://github.com/Sarquella/MutableDataSource/blob/master/LICENSE)
6187

0 commit comments

Comments
 (0)