mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-22 16:23:50 +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
|
* Extension `PaginationResult.thisPageIfNotEmpty` now is typed and will return `PaginationResult?` with the same
|
||||||
generic type as income `PaginationResult`
|
generic type as income `PaginationResult`
|
||||||
* New extension `PaginationResult.currentPageIfNotEmpty` - shortcut for `PaginationResult.thisPageIfNotEmpty`
|
* 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`:
|
* `Coroutines`:
|
||||||
* Rewrite `subscribeSafelyWithoutExceptions`
|
* Rewrite `subscribeSafelyWithoutExceptions`
|
||||||
* Now `subscribeSafelyWithoutExceptions` will use default handler instead of skipping
|
* Now `subscribeSafelyWithoutExceptions` will use default handler instead of skipping
|
||||||
* New extension `subscribeSafelySkippingExceptions`
|
* New extension `subscribeSafelySkippingExceptions`
|
||||||
* `Repos`
|
* `Repos`
|
||||||
* New subproject `repos.cache` - this subproject will contain repos with data caching mechanisms
|
* New subproject `repos.cache` - this subproject will contain repos with data caching mechanisms
|
||||||
* `Pagination`
|
* Most old `doForAll` methods have been deprecated
|
||||||
* 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
|
|
||||||
|
|
||||||
## 0.4.30
|
## 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.*
|
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(
|
suspend fun <T> getAll(
|
||||||
initialPagination: Pagination = FirstPagePagination(),
|
initialPagination: Pagination = FirstPagePagination(),
|
||||||
paginationMapper: (PaginationResult<T>) -> Pagination?,
|
paginationMapper: (PaginationResult<T>) -> Pagination?,
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos.cache
|
package dev.inmo.micro_utils.repos.cache
|
||||||
|
|
||||||
import dev.inmo.micro_utils.repos.*
|
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.Mutex
|
||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos
|
package dev.inmo.micro_utils.repos
|
||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
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
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
interface ReadOneToManyKeyValueRepo<Key, Value> : Repo {
|
interface ReadOneToManyKeyValueRepo<Key, Value> : Repo {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos
|
package dev.inmo.micro_utils.repos
|
||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
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
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
interface ReadStandardKeyValueRepo<Key, Value> : Repo {
|
interface ReadStandardKeyValueRepo<Key, Value> : Repo {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package dev.inmo.micro_utils.repos.pagination
|
package dev.inmo.micro_utils.repos.pagination
|
||||||
|
|
||||||
import dev.inmo.micro_utils.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
|
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
|
||||||
|
|
||||||
@Deprecated("Will be removed soon due to redundancy. Can be replaced with other doForAll extensions")
|
@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
|
package dev.inmo.micro_utils.repos.pagination
|
||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
|
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
||||||
import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo
|
import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo
|
||||||
|
|
||||||
@Deprecated("Will be removed soon due to redundancy")
|
@Deprecated("Will be removed soon due to redundancy")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.micro_utils.repos.pagination
|
package dev.inmo.micro_utils.repos.pagination
|
||||||
|
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
|
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
||||||
import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo
|
import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo
|
||||||
|
|
||||||
@Deprecated("Will be removed soon due to redundancy")
|
@Deprecated("Will be removed soon due to redundancy")
|
||||||
|
Loading…
Reference in New Issue
Block a user