mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-16 05:52:22 +00:00
alsoInvalidate, alsoDoInvalidate, singleSuspend, factorySuspend
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package dev.inmo.micro_utils.repos.cache
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
interface InvalidatableRepo {
|
||||
/**
|
||||
* Invalidates its internal data. It __may__ lead to autoreload of data. In case when repo makes autoreload,
|
||||
@@ -8,4 +11,14 @@ interface InvalidatableRepo {
|
||||
suspend fun invalidate()
|
||||
}
|
||||
|
||||
suspend fun <T : InvalidatableRepo> T.alsoInvalidate() = also {
|
||||
invalidate()
|
||||
}
|
||||
|
||||
fun <T : InvalidatableRepo> T.alsoDoInvalidate(scope: CoroutineScope) = also {
|
||||
scope.launchLoggingDropExceptions {
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
typealias CacheRepo = InvalidatableRepo
|
||||
|
Reference in New Issue
Block a user