Skip to content

Commit

Permalink
* Added missing [value] function to Preferences.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
iZakirSheikh committed Nov 24, 2022
1 parent 4c5063d commit 7c57883
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions preferences/src/main/java/com/primex/preferences/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,16 @@ fun <S, O> Preferences.observeAsState(key: Key1<S, O>): State<O?> = observe(key
@NonRestartableComposable
fun <S, O> Preferences.observeAsState(key: Key2<S, O>): State<O> = observe(key = key) as State<O>


/**
* @return the raw value from the [Preferences] linked with [key]
*/
@WorkerThread
fun <S, O> Preferences.value(key: Key1<S, O>): O? = runBlocking { this@value[key].first() }

/**
* @see [value]
*/
@WorkerThread
fun <S, O> Preferences.value(key: Key2<S, O>): O = runBlocking { this@value[key].first() }

0 comments on commit 7c57883

Please sign in to comment.