-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace KStore with multiplatform-settings.
KStore had a requirement that values could only be read or written in a suspending context, which was horribly limiting in some cases.
- Loading branch information
1 parent
1ebcb4d
commit 64f8f2b
Showing
25 changed files
with
256 additions
and
272 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
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
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
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
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
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
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
16 changes: 5 additions & 11 deletions
16
app/common/src/commonMain/kotlin/sh/christian/ozone/login/LoginRepository.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,26 +1,20 @@ | ||
package sh.christian.ozone.login | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.launch | ||
import me.tatarka.inject.annotations.Inject | ||
import sh.christian.ozone.app.Supervisor | ||
import sh.christian.ozone.di.SingleInApp | ||
import sh.christian.ozone.login.auth.AuthInfo | ||
import sh.christian.ozone.store.PersistentStorage | ||
import sh.christian.ozone.store.preference | ||
import sh.christian.ozone.store.nullablePreference | ||
|
||
@Inject | ||
@SingleInApp | ||
class LoginRepository( | ||
storage: PersistentStorage, | ||
) : Supervisor() { | ||
private val authPreference = storage.preference<AuthInfo>("auth-info", null) | ||
) { | ||
private val authPreference = storage.nullablePreference<AuthInfo>("auth-info", null) | ||
|
||
fun setAuth(authInfo: AuthInfo?) { | ||
requireCoroutineScope().launch { | ||
authPreference.set(authInfo) | ||
} | ||
} | ||
var auth: AuthInfo? by authPreference | ||
|
||
fun auth(): Flow<AuthInfo?> = authPreference.updates | ||
fun authFlow(): Flow<AuthInfo?> = authPreference.updates | ||
} |
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
Oops, something went wrong.