I'm trying to integrate a complex android view (Ma...
# compose
d
I'm trying to integrate a complex android view (Mapbox) with compose. I can't figure out how to handle updating/getting state that's "owned" by the view. For example, I was planning on the following api
Copy code
val state = rememberMapboxState(initialPosition, style)
MapboxView(state)

// later
state.animatePosition(newPosition)
The problem is I can't figure out how to have a method on the state trigger an update to the
AndroidView
. I'm considering having the state have a flow of events that the
MapboxView
attaches to in the `AndroidView`'s
update
, but I was wondering if there's a better approach
d
I could be wrong about this, but I believe in your
MapboxState
the position member would need to be a
MutableState
. Since the entire state is passed into your
MapboxView
(which I'm assuming is your composable wrapper?), when that state is updated (such as by calling
animatePosition
) then your mapbox composable will automatically recompose
d
Thanks. The problem is that model (state tracked in parent, auto-recompose on change) doesn't work with this specific example because this view really wants to keep the state itself for various reasons
I ended up solving it by having the component register the MapboxState with the view so that you can call methods on the state you passed in and have them forwarded to the view