Skip to content

Commit 5a43fb4

Browse files
committed
bug fix,variable watcher does not update when watchable list is empty
1 parent 1eeb400 commit 5a43fb4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ val projectTargetSdk by ext(33)
1919

2020
allprojects {
2121
group = "ir.amirab.debugboard"
22-
version = "0.3.0"
22+
version = "0.3.1"
2323
repositories {
2424
google()
2525
mavenCentral()

core/core/src/main/kotlin/ir/amirab/debugboard/core/plugin/watcher/VarWatcher.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package ir.amirab.debugboard.core.plugin.watcher
33
import kotlinx.coroutines.flow.*
44

55

6-
class VariableWatcher:IVariableWatcher {
6+
class VariableWatcher : IVariableWatcher {
77
override val watchables: MutableStateFlow<List<Watchable<*>>> = MutableStateFlow(emptyList<Watchable<*>>())
88

99
override fun addWatch(watchable: Watchable<*>) {
@@ -24,7 +24,11 @@ class VariableWatcher:IVariableWatcher {
2424
val names = p.map {
2525
it.name
2626
}
27-
val x = combine(
27+
//combine function does not emit when [flows] variable is empty! we manually emit an empty list instead
28+
if (flows.isEmpty()) {
29+
return flowOf(emptyList())
30+
}
31+
return combine(
2832
flows = flows
2933
) {
3034
it.zip(names).map { pair: Pair<Any?, String> ->
@@ -34,8 +38,6 @@ class VariableWatcher:IVariableWatcher {
3438
)
3539
}
3640
}
37-
38-
return x
3941
}
4042

4143

0 commit comments

Comments
 (0)