Ali Zarei
Ali Zarei

Reputation: 3753

Android MVVM dialog viewmodel

I'm developing an app with MVVM pattern and architecture components viewmodel with hilt di. Now I want to use viewmodel in dialog but dialog doesn't have by viewModels() delegation to initialize viewmodel. Any idea?

Upvotes: 1

Views: 1063

Answers (1)

Róbert Nagy
Róbert Nagy

Reputation: 7670

by viewModels() is a Fragment extension function. If you need a ViewModel probably you also need to use a FragmentDialog instead of your current implementation for better separation.

With FragmentDialog by viewModel should work, since FragmentDialog extends Fragment

Upvotes: 2

Related Questions