File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed
app/src/commonMain/kotlin/xyz/junerver/composehooks/example
hooks/src/commonMain/kotlin/xyz/junerver/compose/hooks/utils Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import androidx.compose.material3.Surface
8
8
import androidx.compose.material3.Text
9
9
import androidx.compose.runtime.Composable
10
10
import kotlin.random.Random
11
+ import xyz.junerver.compose.hooks.useEffect
11
12
import xyz.junerver.compose.hooks.useList
12
13
import xyz.junerver.composehooks.ui.component.TButton
13
14
@@ -21,6 +22,9 @@ import xyz.junerver.composehooks.ui.component.TButton
21
22
@Composable
22
23
fun UseListExample () {
23
24
val listState = useList(1 , 2 , 3 )
25
+ useEffect(listState) {
26
+ println (" list change!" )
27
+ }
24
28
Surface {
25
29
Column {
26
30
Row {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package xyz.junerver.compose.hooks.utils
2
2
3
3
import androidx.compose.runtime.Composable
4
4
import androidx.compose.runtime.State
5
+ import androidx.compose.runtime.snapshots.SnapshotStateList
5
6
import kotlin.contracts.ExperimentalContracts
6
7
import kotlin.contracts.InvocationKind
7
8
import kotlin.contracts.contract
@@ -35,6 +36,7 @@ internal inline fun unwrap(deps: Array<out Any?>) = deps.map {
35
36
when (it) {
36
37
is State <* > -> it.value
37
38
is Ref <* > -> it.observeAsState().value
39
+ is SnapshotStateList <* > -> it.toList()
38
40
else -> it
39
41
}
40
42
}.toTypedArray()
You can’t perform that action at this time.
0 commit comments