mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-22 08:13:49 +00:00
replacement of doForAll and getAll
This commit is contained in:
parent
c1557cff27
commit
30b70e9984
19
CHANGELOG.md
19
CHANGELOG.md
@ -10,22 +10,21 @@
|
||||
* Extension `PaginationResult.thisPageIfNotEmpty` now is typed and will return `PaginationResult?` with the same
|
||||
generic type as income `PaginationResult`
|
||||
* New extension `PaginationResult.currentPageIfNotEmpty` - shortcut for `PaginationResult.thisPageIfNotEmpty`
|
||||
* New common functions. They were created as replacements for currently available for more comfortable work
|
||||
with repos pagination:
|
||||
* `doForAll`
|
||||
* `doForAllWithNextPaging`
|
||||
* `doForAllWithCurrentPaging`
|
||||
* `getAll`
|
||||
* `getAllWithNextPaging`
|
||||
* `getAllWithCurrentPaging`
|
||||
* `Coroutines`:
|
||||
* Rewrite `subscribeSafelyWithoutExceptions`
|
||||
* Now `subscribeSafelyWithoutExceptions` will use default handler instead of skipping
|
||||
* New extension `subscribeSafelySkippingExceptions`
|
||||
* `Repos`
|
||||
* New subproject `repos.cache` - this subproject will contain repos with data caching mechanisms
|
||||
* `Pagination`
|
||||
* New common functions. They were created as replacements for currently available for more comfortable work
|
||||
with repos pagination:
|
||||
* `doForAll`
|
||||
* `doForAllWithNextPaging`
|
||||
* `doForAllWithCurrentPaging`
|
||||
* `getAll`
|
||||
* `getAllWithNextPaging`
|
||||
* `getAllWithCurrentPaging`
|
||||
* Most old `doForAll` methods have been deprecated
|
||||
* Most old `doForAll` methods have been deprecated
|
||||
|
||||
## 0.4.30
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
package dev.inmo.micro_utils.pagination.utils
|
||||
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
|
||||
suspend fun <T> doForAll(
|
||||
initialPagination: Pagination = FirstPagePagination(),
|
||||
paginationMapper: (PaginationResult<T>) -> Pagination?,
|
||||
block: suspend (Pagination) -> PaginationResult<T>
|
||||
) {
|
||||
doWithPagination(initialPagination) {
|
||||
block(it).let(paginationMapper)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun <T> doForAllWithNextPaging(
|
||||
initialPagination: Pagination = FirstPagePagination(),
|
||||
block: suspend (Pagination) -> PaginationResult<T>
|
||||
) {
|
||||
doForAll(
|
||||
initialPagination,
|
||||
{ it.nextPageIfNotEmpty() },
|
||||
block
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun <T> doAllWithCurrentPaging(
|
||||
initialPagination: Pagination = FirstPagePagination(),
|
||||
block: suspend (Pagination) -> PaginationResult<T>
|
||||
) {
|
||||
doForAll(
|
||||
initialPagination,
|
||||
{ it.thisPageIfNotEmpty() },
|
||||
block
|
||||
)
|
||||
}
|
@ -1,39 +1,7 @@
|
||||
package dev.inmo.micro_utils.repos.pagination
|
||||
package dev.inmo.micro_utils.pagination.utils
|
||||
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
|
||||
suspend fun <T> doForAll(
|
||||
initialPagination: Pagination = FirstPagePagination(),
|
||||
paginationMapper: (PaginationResult<T>) -> Pagination?,
|
||||
block: suspend (Pagination) -> PaginationResult<T>
|
||||
) {
|
||||
doWithPagination(initialPagination) {
|
||||
block(it).let(paginationMapper)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun <T> doForAllWithNextPaging(
|
||||
initialPagination: Pagination = FirstPagePagination(),
|
||||
block: suspend (Pagination) -> PaginationResult<T>
|
||||
) {
|
||||
doForAll(
|
||||
initialPagination,
|
||||
{ it.nextPageIfNotEmpty() },
|
||||
block
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun <T> doAllWithCurrentPaging(
|
||||
initialPagination: Pagination = FirstPagePagination(),
|
||||
block: suspend (Pagination) -> PaginationResult<T>
|
||||
) {
|
||||
doForAll(
|
||||
initialPagination,
|
||||
{ it.thisPageIfNotEmpty() },
|
||||
block
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun <T> getAll(
|
||||
initialPagination: Pagination = FirstPagePagination(),
|
||||
paginationMapper: (PaginationResult<T>) -> Pagination?,
|
@ -1,7 +1,7 @@
|
||||
package dev.inmo.micro_utils.repos.cache
|
||||
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
import dev.inmo.micro_utils.repos.pagination.getAllWithNextPaging
|
||||
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package dev.inmo.micro_utils.repos
|
||||
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.repos.pagination.getAllWithNextPaging
|
||||
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface ReadOneToManyKeyValueRepo<Key, Value> : Repo {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package dev.inmo.micro_utils.repos
|
||||
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.repos.pagination.doAllWithCurrentPaging
|
||||
import dev.inmo.micro_utils.pagination.utils.doAllWithCurrentPaging
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface ReadStandardKeyValueRepo<Key, Value> : Repo {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package dev.inmo.micro_utils.repos.pagination
|
||||
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.pagination.utils.doForAllWithNextPaging
|
||||
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
||||
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
|
||||
|
||||
@Deprecated("Will be removed soon due to redundancy. Can be replaced with other doForAll extensions")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.inmo.micro_utils.repos.pagination
|
||||
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
||||
import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo
|
||||
|
||||
@Deprecated("Will be removed soon due to redundancy")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.inmo.micro_utils.repos.pagination
|
||||
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
||||
import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo
|
||||
|
||||
@Deprecated("Will be removed soon due to redundancy")
|
||||
|
Loading…
Reference in New Issue
Block a user