Is there a way to reinstall `pointerInput`? It doe...
# compose
v
Is there a way to reinstall
pointerInput
? It doesn’t react on lambda changes and always use only first served lambda. Below prints only
pointerInput 2
and doesn’t print anything on switch toggle.
Copy code
@Preview
@Composable
fun PointInputTest() {
    var toggled: Boolean by remember { mutableStateOf(false) }
    Column {
        Switch(checked = toggled, onCheckedChange = { toggled = !toggled })
        Box(
            modifier = Modifier
                .size(50.dp)
                .background(Color.Red)
                .run {
                    if (toggled) {
                        pointerInput {
                            println("pointerInput 1")
                        }
                    } else {
                        pointerInput {
                            println("pointerInput 2")
                        }
                    }
                }
        )
    }
}
a
No, this is an artifact of the way that
Modifier.composed {}
modifiers work plus the current implementation decision to not re-launch
pointerInput {}
modifiers on lambda capture change. Some of this predates the
rememberUpdatedState
API which solves some of the use cases that the original decision not to re-launch was targeting, so it might be worth us re-evaluating it.
Feel free to file a bug on the issue tracker for us to take another look at it.
👌 1
At the moment I'm inclined to say we should change the implementation to re-launch for a new lambda capture, which would make your code example work as you expect
v