I want to re execute some code for view rendering ...
# compose-wear
l
I want to re execute some code for view rendering in the composable method. How do I implement it? Do you have a general idea. thank you!
b
I can't understand your question exactly. You have composable items and some value of item can change to other value by another method? After then, you want to adopt the changed value to your composable item? Am I Right? If you want that idea then using "State". For example, you want progress bar and progress value affected by other function then using that progress value as "State". And you use that state on your compose code. if your state changed then your compose item is re composed with changed value. If you want some complex action with changed value or other trigger, then use "Side Effect" with "State". You can use state to trigger for execute inner code block of side effect.
l
Thanks for your reply. My current usage scenario is to load Lottie animation with compose. Then I want the animation to play again after playing it once. If I set repeat = 3, there will be errors in every Lottie animation, so I want to let compose reload the animation. I just tried to add code that can't draw UI in effect.
b
I use only frame animation and compose animation in wear, so it is difficult to give an exact answer. If you want to restart the animation when the Lottie animation's end state, you can set the Lottie animation state to mutableState and trigger the animation again using the launched effect when the mutableState reaches the end. Also, Lottie provides the Lottie-compose library, so it might be helpful to look at that part. (https://gpeal.medium.com/lottie-android-and-compose-4-0-e6340914421)