-
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.
Merge pull request #58 from stslex/dev
Dev
- Loading branch information
Showing
18 changed files
with
166 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
object AppVersions { | ||
const val versionName = "1.62" | ||
const val versionCode = 8 | ||
const val versionName = "1.63" | ||
const val versionCode = 9 | ||
} |
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
24 changes: 23 additions & 1 deletion
24
core/core/src/main/java/st/slex/csplashscreen/core/core/CoroutineExt.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,4 +1,26 @@ | ||
package st.slex.csplashscreen.core.core | ||
|
||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.combine as combinePrimary | ||
import kotlinx.coroutines.flow.map as mapPrimary | ||
|
||
object CoroutineExt { | ||
} | ||
|
||
fun <T, R> StateFlow<T>.mapState( | ||
transform: (a: T) -> R, | ||
): StateFlow<R> = TransformableStateFlow( | ||
getValue = { transform(this.value) }, | ||
flow = mapPrimary(transform = transform), | ||
) | ||
|
||
fun <T1, T2, R> StateFlow<T1>.combineState( | ||
flow: StateFlow<T2>, | ||
transform: (a: T1, b: T2) -> R, | ||
): StateFlow<R> = TransformableStateFlow( | ||
getValue = { transform(this.value, flow.value) }, | ||
flow = combinePrimary( | ||
flow = flow, | ||
transform = transform, | ||
), | ||
) | ||
} |
28 changes: 28 additions & 0 deletions
28
core/core/src/main/java/st/slex/csplashscreen/core/core/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,28 @@ | ||
package st.slex.csplashscreen.core.core | ||
|
||
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.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) | ||
} | ||
} | ||
} |
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
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.