I have a compose app and am struggling with best practices for using koin’s
getViewModel()
from within a compose
Dialog
. Since the viewmodel is scoped to the fragment, the same viewmodel instance is returned each time (furthermore, this is regardless of any
parametersOf
args). So, how are we supposed to deal with this? I want to get a new instance every time the user taps on whatever to bring up the
Dialog
. Only the same instance should be returned with there is a config change etc. This is particularly an issue when the dialog contains a text field, because consider when the user makes some edit to the text and then hits cancel. By default, the dialog will show the old cancelled text when next invoked, unless we take care to reset all relevant
MutableState
which seems like something we shouldn’t need to handle.
I know this has been asked previously, but I haven’t seen any proper solution.