minimise
minimise copied to clipboard
MainActivity setContent{} Recomposed
First I'm not sure if this is an issue in your code base or not, but we implemented something very similar but with RxJava. I left a comment on your great blog https://medium.com/google-developer-experts/modular-navigation-with-jetpack-compose-fda9f6b2bef7 that explains how the MainActivity setContent{} block may be getting recomposed. Figured I'd share our learnings with you incase you see it yourself too.
Here's the comment: Great article and we are exploring this pattern. We did run into an issue where the commands were being subscribed to as state (RxJava .subscribeAsState(...) ) and that cause the setContent{} block of code to be recomposed. This was easily seen as we were using a black screen, and anytime we navigated it would flash white when setContent{} was hit again. We were able to get around this by using a normal Rxjava .subscribe() pattern, but needed to ensure we were on the main thread prior to calling our navController object. I'm thinking the same could be done via coroutines, but I'm not familiar with them yet. Hope this helps others in the future.