-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b8ab69
commit 96fed24
Showing
4 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
kstorage/src/commonMain/kotlin/ru/astrainteractive/klibs/kstorage/suspend/SuspendKrate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
package ru.astrainteractive.klibs.kstorage.suspend | ||
|
||
import ru.astrainteractive.klibs.kstorage.api.Krate | ||
import ru.astrainteractive.klibs.kstorage.api.cache.CacheOwner | ||
|
||
/** | ||
* Same as [Krate], [SuspendKrate] is a wrapper for your favorite key-value storage library | ||
*/ | ||
interface SuspendKrate<T> : CacheOwner<T> { | ||
/** | ||
* Load value from storage and update [cachedValue] | ||
*/ | ||
suspend fun loadAndGet(): T | ||
} |
12 changes: 12 additions & 0 deletions
12
...e/src/commonMain/kotlin/ru/astrainteractive/klibs/kstorage/suspend/SuspendMutableKrate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
package ru.astrainteractive.klibs.kstorage.suspend | ||
|
||
import ru.astrainteractive.klibs.kstorage.api.MutableKrate | ||
|
||
/** | ||
* Same as [MutableKrate], [SuspendMutableKrate] allows you to save/load values from your storage without | ||
* depending on SharedPreferences or other library | ||
*/ | ||
interface SuspendMutableKrate<T> : SuspendKrate<T> { | ||
/** | ||
* Save new value into storage and update current | ||
*/ | ||
suspend fun save(value: T) | ||
|
||
/** | ||
* Reset value to default | ||
*/ | ||
suspend fun reset() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters