mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-21 08:07:16 +00:00
doForAll and getForAll not suspend
This commit is contained in:
parent
27822a8a66
commit
7b5e84f80b
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## 0.10.7
|
## 0.10.7
|
||||||
|
|
||||||
|
* `Pagination`:
|
||||||
|
* Now it is possible to use `doForAll*` and `getForAll` functions in non suspend places
|
||||||
|
|
||||||
## 0.10.6
|
## 0.10.6
|
||||||
|
|
||||||
* `Versions`
|
* `Versions`
|
||||||
|
@ -2,19 +2,19 @@ package dev.inmo.micro_utils.pagination.utils
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
|
|
||||||
suspend fun <T> doForAll(
|
inline fun <T> doForAll(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
paginationMapper: (PaginationResult<T>) -> Pagination?,
|
paginationMapper: (PaginationResult<T>) -> Pagination?,
|
||||||
block: suspend (Pagination) -> PaginationResult<T>
|
block: (Pagination) -> PaginationResult<T>
|
||||||
) {
|
) {
|
||||||
doWithPagination(initialPagination) {
|
doWithPagination(initialPagination) {
|
||||||
block(it).let(paginationMapper)
|
block(it).let(paginationMapper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun <T> doForAllWithNextPaging(
|
inline fun <T> doForAllWithNextPaging(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
block: suspend (Pagination) -> PaginationResult<T>
|
block: (Pagination) -> PaginationResult<T>
|
||||||
) {
|
) {
|
||||||
doForAll(
|
doForAll(
|
||||||
initialPagination,
|
initialPagination,
|
||||||
@ -23,9 +23,9 @@ suspend fun <T> doForAllWithNextPaging(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun <T> doAllWithCurrentPaging(
|
inline fun <T> doAllWithCurrentPaging(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
block: suspend (Pagination) -> PaginationResult<T>
|
block: (Pagination) -> PaginationResult<T>
|
||||||
) {
|
) {
|
||||||
doForAll(
|
doForAll(
|
||||||
initialPagination,
|
initialPagination,
|
||||||
@ -34,7 +34,7 @@ suspend fun <T> doAllWithCurrentPaging(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun <T> doForAllWithCurrentPaging(
|
inline fun <T> doForAllWithCurrentPaging(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
block: suspend (Pagination) -> PaginationResult<T>
|
block: (Pagination) -> PaginationResult<T>
|
||||||
) = doAllWithCurrentPaging(initialPagination, block)
|
) = doAllWithCurrentPaging(initialPagination, block)
|
||||||
|
@ -2,10 +2,10 @@ package dev.inmo.micro_utils.pagination.utils
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
|
|
||||||
suspend fun <T> getAll(
|
inline fun <T> getAll(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
paginationMapper: (PaginationResult<T>) -> Pagination?,
|
paginationMapper: (PaginationResult<T>) -> Pagination?,
|
||||||
block: suspend (Pagination) -> PaginationResult<T>
|
block: (Pagination) -> PaginationResult<T>
|
||||||
): List<T> {
|
): List<T> {
|
||||||
val results = mutableListOf<T>()
|
val results = mutableListOf<T>()
|
||||||
doForAll(initialPagination, paginationMapper) {
|
doForAll(initialPagination, paginationMapper) {
|
||||||
@ -16,46 +16,45 @@ suspend fun <T> getAll(
|
|||||||
return results.toList()
|
return results.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun <T, R> R.getAllBy(
|
inline fun <T, R> R.getAllBy(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
paginationMapper: R.(PaginationResult<T>) -> Pagination?,
|
paginationMapper: R.(PaginationResult<T>) -> Pagination?,
|
||||||
block: suspend R.(Pagination) -> PaginationResult<T>
|
block: R.(Pagination) -> PaginationResult<T>
|
||||||
): List<T> = getAll(
|
): List<T> = getAll(
|
||||||
initialPagination,
|
initialPagination,
|
||||||
{ paginationMapper(it) },
|
{ paginationMapper(it) },
|
||||||
{ block(it) }
|
{ block(it) }
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun <T> getAllWithNextPaging(
|
inline fun <T> getAllWithNextPaging(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
block: suspend (Pagination) -> PaginationResult<T>
|
block: (Pagination) -> PaginationResult<T>
|
||||||
): List<T> = getAll(
|
): List<T> = getAll(
|
||||||
initialPagination,
|
initialPagination,
|
||||||
{ it.nextPageIfNotEmpty() },
|
{ it.nextPageIfNotEmpty() },
|
||||||
block
|
block
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun <T, R> R.getAllByWithNextPaging(
|
inline fun <T, R> R.getAllByWithNextPaging(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
block: suspend R.(Pagination) -> PaginationResult<T>
|
block: R.(Pagination) -> PaginationResult<T>
|
||||||
): List<T> = getAllWithNextPaging(
|
): List<T> = getAllWithNextPaging(
|
||||||
initialPagination,
|
initialPagination,
|
||||||
{ block(it) }
|
{ block(it) }
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun <T> getAllWithCurrentPaging(
|
inline fun <T> getAllWithCurrentPaging(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
block: suspend (Pagination) -> PaginationResult<T>
|
block: (Pagination) -> PaginationResult<T>
|
||||||
): List<T> = getAll(
|
): List<T> = getAll(
|
||||||
initialPagination,
|
initialPagination,
|
||||||
{ it.currentPageIfNotEmpty() },
|
{ it.currentPageIfNotEmpty() },
|
||||||
block
|
block
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun <T, R> R.getAllByWithCurrentPaging(
|
inline fun <T, R> R.getAllByWithCurrentPaging(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
block: suspend R.(Pagination) -> PaginationResult<T>
|
block: R.(Pagination) -> PaginationResult<T>
|
||||||
): List<T> = getAllWithCurrentPaging(
|
): List<T> = getAllWithCurrentPaging(
|
||||||
initialPagination,
|
initialPagination
|
||||||
{ block(it) }
|
) { block(it) }
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user