[Solved]
Can a composable be skipped even if a parameter to a modifier has changed? Example in 🧵
Landry Norris
08/24/2022, 1:27 PM
I have an interface that handles touch events for a Canvas composable called DrawHandler. I have the following method
Copy code
@Composable
fun Drawing(drawObjects: List<DrawObject>, drawHandler: TouchHandler) {
println("Draw handler is $drawHandler in drawing")
Canvas(modifier = Modifier.fillMaxSize().handleDraw(drawHandler).clipToBounds()) {
... draw stuff based on drawObjects
}
}
I need to be able to swap out my draw handler, and the new one should receive touch events.
Landry Norris
08/24/2022, 1:28 PM
I see that the value printed by the log changes from DrawImpl@49051c9 to DrawImpl@add3299, but my log inside handleDraw only says it gets called with DrawImpl@49051c9
Landry Norris
08/24/2022, 1:30 PM
Just realized my mistake. If it helps anyone, my handleDraw method used pointerInput(Unit) instead of pointerInput(drawHandler)
Landry Norris
08/24/2022, 1:31 PM
Changing it to pointerInput(drawHandler) caused changes to drawHandler to force recomposition of Canvas.