Compare commits

..

No commits in common. "846b5c87c985ea57bda6ea5f287ccf3096475222" and "36f4e7ec37f93b0620dc1cfa54fda355e0eac37d" have entirely different histories.

4 changed files with 25 additions and 29 deletions

View File

@ -1,10 +1,5 @@
# Changelog
## 0.10.7
* `Pagination`:
* Now it is possible to use `doForAll*` and `getForAll` functions in non suspend places
## 0.10.6
* `Versions`

View File

@ -14,5 +14,5 @@ crypto_js_version=4.1.1
# Project data
group=dev.inmo
version=0.10.7
android_code_version=122
version=0.10.6
android_code_version=121

View File

@ -2,19 +2,19 @@ package dev.inmo.micro_utils.pagination.utils
import dev.inmo.micro_utils.pagination.*
inline fun <T> doForAll(
suspend fun <T> doForAll(
initialPagination: Pagination = FirstPagePagination(),
paginationMapper: (PaginationResult<T>) -> Pagination?,
block: (Pagination) -> PaginationResult<T>
block: suspend (Pagination) -> PaginationResult<T>
) {
doWithPagination(initialPagination) {
block(it).let(paginationMapper)
}
}
inline fun <T> doForAllWithNextPaging(
suspend fun <T> doForAllWithNextPaging(
initialPagination: Pagination = FirstPagePagination(),
block: (Pagination) -> PaginationResult<T>
block: suspend (Pagination) -> PaginationResult<T>
) {
doForAll(
initialPagination,
@ -23,9 +23,9 @@ inline fun <T> doForAllWithNextPaging(
)
}
inline fun <T> doAllWithCurrentPaging(
suspend fun <T> doAllWithCurrentPaging(
initialPagination: Pagination = FirstPagePagination(),
block: (Pagination) -> PaginationResult<T>
block: suspend (Pagination) -> PaginationResult<T>
) {
doForAll(
initialPagination,
@ -34,7 +34,7 @@ inline fun <T> doAllWithCurrentPaging(
)
}
inline fun <T> doForAllWithCurrentPaging(
suspend fun <T> doForAllWithCurrentPaging(
initialPagination: Pagination = FirstPagePagination(),
block: (Pagination) -> PaginationResult<T>
block: suspend (Pagination) -> PaginationResult<T>
) = doAllWithCurrentPaging(initialPagination, block)

View File

@ -2,10 +2,10 @@ package dev.inmo.micro_utils.pagination.utils
import dev.inmo.micro_utils.pagination.*
inline fun <T> getAll(
suspend fun <T> getAll(
initialPagination: Pagination = FirstPagePagination(),
paginationMapper: (PaginationResult<T>) -> Pagination?,
block: (Pagination) -> PaginationResult<T>
block: suspend (Pagination) -> PaginationResult<T>
): List<T> {
val results = mutableListOf<T>()
doForAll(initialPagination, paginationMapper) {
@ -16,45 +16,46 @@ inline fun <T> getAll(
return results.toList()
}
inline fun <T, R> R.getAllBy(
suspend fun <T, R> R.getAllBy(
initialPagination: Pagination = FirstPagePagination(),
paginationMapper: R.(PaginationResult<T>) -> Pagination?,
block: R.(Pagination) -> PaginationResult<T>
block: suspend R.(Pagination) -> PaginationResult<T>
): List<T> = getAll(
initialPagination,
{ paginationMapper(it) },
{ block(it) }
)
inline fun <T> getAllWithNextPaging(
suspend fun <T> getAllWithNextPaging(
initialPagination: Pagination = FirstPagePagination(),
block: (Pagination) -> PaginationResult<T>
block: suspend (Pagination) -> PaginationResult<T>
): List<T> = getAll(
initialPagination,
{ it.nextPageIfNotEmpty() },
block
)
inline fun <T, R> R.getAllByWithNextPaging(
suspend fun <T, R> R.getAllByWithNextPaging(
initialPagination: Pagination = FirstPagePagination(),
block: R.(Pagination) -> PaginationResult<T>
block: suspend R.(Pagination) -> PaginationResult<T>
): List<T> = getAllWithNextPaging(
initialPagination,
{ block(it) }
)
inline fun <T> getAllWithCurrentPaging(
suspend fun <T> getAllWithCurrentPaging(
initialPagination: Pagination = FirstPagePagination(),
block: (Pagination) -> PaginationResult<T>
block: suspend (Pagination) -> PaginationResult<T>
): List<T> = getAll(
initialPagination,
{ it.currentPageIfNotEmpty() },
block
)
inline fun <T, R> R.getAllByWithCurrentPaging(
suspend fun <T, R> R.getAllByWithCurrentPaging(
initialPagination: Pagination = FirstPagePagination(),
block: R.(Pagination) -> PaginationResult<T>
block: suspend R.(Pagination) -> PaginationResult<T>
): List<T> = getAllWithCurrentPaging(
initialPagination
) { block(it) }
initialPagination,
{ block(it) }
)