Skip to content

Commit

Permalink
add more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
makeevrserg committed Aug 3, 2024
1 parent 4b8ab69 commit 96fed24
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ru.astrainteractive.klibs.kstorage.api.value

fun interface ValueSaver<T> {
fun save(value: T)

class Empty<T> : ValueSaver<T> {
override fun save(value: T) = Unit
}
Expand Down
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
}
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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package ru.astrainteractive.klibs.kstorage.suspend.value

import kotlinx.coroutines.flow.Flow

/**
* [FlowProvider] should provide you with flow. Use android.DataStore, for example
*/
fun interface FlowProvider<out T> {
fun provide(): Flow<T?>
}

0 comments on commit 96fed24

Please sign in to comment.