Basically to model any sort of complex Jetpack Compose state do this:
@ComposablefunrememberDraggableActions():ModViewDragState{returnremember{ModViewDragState()}}@StableclassModViewDragState(){// all the complex state goes in here}
Then you can use rememberDraggableActions() just like a normal remember function:
@ComposablefunTestingComplexState(){valstate=rememberDraggableActions()//all complex state can now be accessed through state}
Introduction
This blog post is not going to be an in-depth analysis of every little section of code. Instead, it will act as a simple visual demonstration and example on a alternative way to model compose state
Which as you can see is a lot easier to read and just overall cleaner
The state modeling
All I did was just put all the complex state dealing with the draggable into a class marked with the Stable annotation(allowing compose to skip recomposition if needed).
Thank you for taking the time out of your day to read this blog post of mine. If you have any questions or concerns please comment below or reach out to me on Twitter.
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)