Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MainActivity setContent{} Recomposed #37

Open
mattgraham1 opened this issue Aug 5, 2021 · 0 comments
Open

MainActivity setContent{} Recomposed #37

mattgraham1 opened this issue Aug 5, 2021 · 0 comments

Comments

@mattgraham1
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant