-
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
Showing
18 changed files
with
185 additions
and
122 deletions.
There are no files selected for viewing
9 changes: 0 additions & 9 deletions
9
app/src/main/java/com/stslex/aproselection/SelectApplication.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
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 |
---|---|---|
|
@@ -6,6 +6,5 @@ interface AuthController { | |
|
||
val isAuth: StateFlow<Boolean?> | ||
|
||
fun init() | ||
suspend fun init() | ||
} | ||
|
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
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/stslex/aproselection/utils/TransformableStateFlow.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.stslex.aproselection.utils | ||
|
||
import kotlinx.coroutines.coroutineScope | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.FlowCollector | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.distinctUntilChanged | ||
import kotlinx.coroutines.flow.map | ||
import kotlinx.coroutines.flow.stateIn | ||
|
||
class TransformableStateFlow<out T>( | ||
val getValue: () -> T, | ||
val flow: Flow<T>, | ||
) : StateFlow<T> { | ||
|
||
override val replayCache: List<T> | ||
get() = listOf(value) | ||
|
||
override val value: T | ||
get() = getValue() | ||
|
||
override suspend fun collect(collector: FlowCollector<T>): Nothing { | ||
coroutineScope { | ||
flow.distinctUntilChanged() | ||
.stateIn(this) | ||
.collect(collector) | ||
} | ||
} | ||
} | ||
|
||
fun <Flow1, Result> StateFlow<Flow1>.mapState( | ||
transform: (a: Flow1) -> Result, | ||
): StateFlow<Result> = TransformableStateFlow( | ||
getValue = { transform(this.value) }, | ||
flow = map(transform = transform), | ||
) |
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
8 changes: 5 additions & 3 deletions
8
core/datastore/src/main/java/com/stslex/aproselection/core/datastore/AppDataStore.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,13 +1,15 @@ | ||
package com.stslex.aproselection.core.datastore | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
interface AppDataStore { | ||
|
||
val uuid: Flow<String> | ||
val token: Flow<String> | ||
val uuid: StateFlow<String> | ||
val token: StateFlow<String> | ||
|
||
suspend fun setUuid(uuid: String) | ||
|
||
suspend fun setToken(token: String) | ||
|
||
suspend fun init() | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...slex/aproselection/core/ui/core/Logger.kt → ...roselection/core/datastore/core/Logger.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
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
Oops, something went wrong.