Hey guys! Just started using compose in a live-gra...
# compose
d
Hey guys! Just started using compose in a live-graph implementation which uses an existing view that live updates from values being produced from Rx. Has anyone had issues with their app freezing due to updating views frequently within the main compose view? Code in thread
Copy code
val dataFlow = produceValues().subscribeAsState(initial = 0)
this is in my main view,
produceValues()
simply spits out a long every 5 seconds. I'm passing the state as a parameter to a Composable which is supposed to render the graph:
Copy code
@Composable
fun renderGraph(state: State<Long>, plotType: PlotType) {
    AndroidView(
        factory = {
            // creates the chart
        },
        modifier = Modifier.fillMaxSize(),
        update = {
            state.value.let { x: Long ->
                // change the graph's data based on this long
            }
        }
    )
}
Does anything about this seem inherently wrong? I was under the impression that I should be making a separate composable function for rendering the graph as compose will only redraw this individual component (rather than the whole main screen). When I run this my app freezes and eventually stops responding
s
check if your factory is not getting called every time you update data.
d
it is not - just the update function which modifies the data attached to the sheet. Should it be calling the factory every time?