Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {

allprojects {
group = "com.rickclephas.kmp"
version = "1.0.0-BETA-10"
version = "1.0.0-BETA-10-kotlin-2.1.21-RC2"

repositories {
mavenCentral()
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlin = "2.1.20"
kotlin = "2.1.21"
kotlinx-coroutines = "1.10.1"
android = "8.2.0"
androidx-lifecycle = "2.8.7"
Expand All @@ -8,8 +8,8 @@ atomicfu = "0.26.1"
# Sample versions
androidx-compose = "2023.10.01"
androidx-fragment = "1.6.2"
ksp = "2.1.20-1.0.31"
nativecoroutines = "1.0.0-ALPHA-41"
ksp = "2.1.21-2.0.1"
nativecoroutines = "1.0.0-ALPHA-43"

[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ open class TimeTravelViewModel: ViewModel() {
* A [StateFlow] that emits the actual time.
*/
@NativeCoroutinesState
val actualTime = clockTime.map { formatTime(it) }
val actualTime: StateFlow<String> = clockTime.map { formatTime(it) }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), "N/A")

private val _travelEffect = MutableStateFlow<TravelEffect?>(viewModelScope, null)
/**
* A [StateFlow] that emits the applied [TravelEffect].
*/
@NativeCoroutinesState
val travelEffect = _travelEffect.asStateFlow()
val travelEffect: StateFlow<TravelEffect?> = _travelEffect.asStateFlow()

/**
* A [StateFlow] that indicates if the [currentTime] is fixed.
* @see startTime
* @see stopTime
*/
@NativeCoroutinesState
val isFixedTime = _travelEffect.map { it is TravelEffect.Fixed }
val isFixedTime: StateFlow<Boolean> = _travelEffect.map { it is TravelEffect.Fixed }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), false)

/**
* A [StateFlow] that emits the current time.
*/
@NativeCoroutinesState
val currentTime = combine(clockTime, _travelEffect) { actualTime, travelEffect ->
val currentTime: StateFlow<String> = combine(clockTime, _travelEffect) { actualTime, travelEffect ->
formatTime(actualTime + travelEffect)
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), "N/A")

Expand Down
Loading