diff --git a/CHANGELOG.md b/CHANGELOG.md index e3d29fa5c48..4682e9d02e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.10.7 + +* `Pagination`: + * Now it is possible to use `doForAll*` and `getForAll` functions in non suspend places + ## 0.10.6 * `Versions` diff --git a/gradle.properties b/gradle.properties index 4f3849b811c..e99c8314392 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.10.6 -android_code_version=121 +version=0.10.7 +android_code_version=122 diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/DoForAll.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/DoForAll.kt index b77f3b59848..63e8cb38eba 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/DoForAll.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/DoForAll.kt @@ -2,19 +2,19 @@ package dev.inmo.micro_utils.pagination.utils import dev.inmo.micro_utils.pagination.* -suspend fun doForAll( +inline fun doForAll( initialPagination: Pagination = FirstPagePagination(), paginationMapper: (PaginationResult) -> Pagination?, - block: suspend (Pagination) -> PaginationResult + block: (Pagination) -> PaginationResult ) { doWithPagination(initialPagination) { block(it).let(paginationMapper) } } -suspend fun doForAllWithNextPaging( +inline fun doForAllWithNextPaging( initialPagination: Pagination = FirstPagePagination(), - block: suspend (Pagination) -> PaginationResult + block: (Pagination) -> PaginationResult ) { doForAll( initialPagination, @@ -23,9 +23,9 @@ suspend fun doForAllWithNextPaging( ) } -suspend fun doAllWithCurrentPaging( +inline fun doAllWithCurrentPaging( initialPagination: Pagination = FirstPagePagination(), - block: suspend (Pagination) -> PaginationResult + block: (Pagination) -> PaginationResult ) { doForAll( initialPagination, @@ -34,7 +34,7 @@ suspend fun doAllWithCurrentPaging( ) } -suspend fun doForAllWithCurrentPaging( +inline fun doForAllWithCurrentPaging( initialPagination: Pagination = FirstPagePagination(), - block: suspend (Pagination) -> PaginationResult + block: (Pagination) -> PaginationResult ) = doAllWithCurrentPaging(initialPagination, block) diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/GetAll.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/GetAll.kt index 8012a89e47d..da50a9528e2 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/GetAll.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/GetAll.kt @@ -2,10 +2,10 @@ package dev.inmo.micro_utils.pagination.utils import dev.inmo.micro_utils.pagination.* -suspend fun getAll( +inline fun getAll( initialPagination: Pagination = FirstPagePagination(), paginationMapper: (PaginationResult) -> Pagination?, - block: suspend (Pagination) -> PaginationResult + block: (Pagination) -> PaginationResult ): List { val results = mutableListOf() doForAll(initialPagination, paginationMapper) { @@ -16,46 +16,45 @@ suspend fun getAll( return results.toList() } -suspend fun R.getAllBy( +inline fun R.getAllBy( initialPagination: Pagination = FirstPagePagination(), paginationMapper: R.(PaginationResult) -> Pagination?, - block: suspend R.(Pagination) -> PaginationResult + block: R.(Pagination) -> PaginationResult ): List = getAll( initialPagination, { paginationMapper(it) }, { block(it) } ) -suspend fun getAllWithNextPaging( +inline fun getAllWithNextPaging( initialPagination: Pagination = FirstPagePagination(), - block: suspend (Pagination) -> PaginationResult + block: (Pagination) -> PaginationResult ): List = getAll( initialPagination, { it.nextPageIfNotEmpty() }, block ) -suspend fun R.getAllByWithNextPaging( +inline fun R.getAllByWithNextPaging( initialPagination: Pagination = FirstPagePagination(), - block: suspend R.(Pagination) -> PaginationResult + block: R.(Pagination) -> PaginationResult ): List = getAllWithNextPaging( initialPagination, { block(it) } ) -suspend fun getAllWithCurrentPaging( +inline fun getAllWithCurrentPaging( initialPagination: Pagination = FirstPagePagination(), - block: suspend (Pagination) -> PaginationResult + block: (Pagination) -> PaginationResult ): List = getAll( initialPagination, { it.currentPageIfNotEmpty() }, block ) -suspend fun R.getAllByWithCurrentPaging( +inline fun R.getAllByWithCurrentPaging( initialPagination: Pagination = FirstPagePagination(), - block: suspend R.(Pagination) -> PaginationResult + block: R.(Pagination) -> PaginationResult ): List = getAllWithCurrentPaging( - initialPagination, - { block(it) } -) + initialPagination +) { block(it) }