This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Recomposition happens twice! #122
Comments
It looks like you have a lot of side-effects that are not contained within effects. This is likely causing or contributing to the issue. Please take a look at Side-effects in Compose. |
Thanks, but can you mention one of them? This sample doesn't have any IO call! No network or disk access, just the UI, which I cannot think of a way to launch a UI action as an affect! Just give me one example. |
I misunderstood what your code was doing. The particular thing I thought was a side effect is not, at least not directly. I believe the issue here is that you're passing in "actions" as parameters to composable functions, which has a side-effect on the upstream code, causing recomposition. Your Actions are transient and should be handled within callbacks or effects. Instead of accepting an action as a parameter, you would accept a
This isn't a comprehensive code snippet because you need to do a lot of restructuring of your project. This is an issue with your code at the Compose level. Molecule isn't contributing to this. |
Thank you. This is exactly what's implemented in the sample of Molecule in this repository. I want to follow these steps, but I have two problems!
do you have any idea? |
I am going to convert this to a discussion because it seems like:
|
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I just pushed source code of a sample here. Everything looks good, except that if you run the code, and click the buttons, you'll see in the Logcat that recomposition is happening twice, once because we launched an action, which is expected, but the other one appeared to happen because of changing of the return value of the nested compose, which is unexpected! I made a workaround for the "previous page" button by launching two actions in a row!
To clarify the problem, I created this commit, so just check out to the-infinit-loop-problem branch. In this branch, after clicking the "previous page" button, it'll call the
MainPresenter
in some kind of a loop until thestack
becomes empty! How can I avoid that infinit loop? Pull requests are welcome. By the way, thanks guys for this awesome library.The text was updated successfully, but these errors were encountered: