Effective use of MoleculeViewModel #473
Unanswered
mwilliams-sfo
asked this question in
Q&A
Replies: 1 comment
-
I see now that since the Molecule scope derives its context from the viewModelScope, including its Job, it does not have to be cancelled separately. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have joined an Android project in which the sample
MoleculeViewModel
has been integrated as the basis of screen state. I am new to the project and not intimately familiar with Compose runtime (so my terminology might be off), and the people who did the integration are not around.My first question was going to be about seeing event loops read stale values from Compose state objects. That's the subject of this question so I'll try the suggestion of
rememberUpdatedState
there.Second, can Compose state that is
remember
ed withinMoleculeViewModel::models
retain its value when the ViewModel has no UI, e.g. its screen is pushed back in the stack? If so, what keeps theremember
s alive independently of the UI?Third, why does
MoleculeViewModel
create a coroutine scope that it never cancels? What, if anything, stops model composition when the ViewModel is destroyed?Beta Was this translation helpful? Give feedback.
All reactions