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

Fix lifetime of Records' ViewModelStores #1097

Merged
merged 2 commits into from
Jan 5, 2024

Conversation

dandc87
Copy link
Contributor

@dandc87 dandc87 commented Jan 3, 2024

Fixes original issue reported in #1065

The fix in #1086 only made sure the correct ViewModelStore was present, but ViewModel.onCleared() is still being called upon stack-pop, not once the Presenter/Ui completely left composition.

This PR tracks both "stack" lifetime and "ui" lifetime and only clears the ViewModelStore when both have been forgotten. I piggybacked on shared RememberType stuff, I hope that's alright.

Also fixes ProvidedValuesLifetimeTest to read the CompositionLocal again, using better special values to hopefully prevent accidental breaking again

Copy link
Contributor

@chrisbanes chrisbanes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

I have a hunch that we can avoid doing all of this by tweaking how the values are stored in NavigableCircuitContent itself, by moving them into the movableContentOf. I'll have a play with that soon, now that we have a nice test case to catch regressions 👌. I don't want to block this on my hunch though.

Copy link
Collaborator

@ZacSweers ZacSweers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ZacSweers ZacSweers added this pull request to the merge queue Jan 5, 2024
Merged via the queue into slackhq:main with commit c84ca08 Jan 5, 2024
2 checks passed
@dandc87 dandc87 deleted the fix-1065-part-2 branch January 5, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants