mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-10-28 23:52:57 +00:00
alsoInvalidate, alsoDoInvalidate, singleSuspend, factorySuspend
This commit is contained in:
1 parent
a4c6c367e3
commit
831bf44e34
6 files changed
+86
-2
No files matched your search
+13
@@ -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