0
Follow
0
View

How to set MainViewModel?

cuiqiang302 注册会员
2023-01-24 21:04

ViewModelProvider is deprecated. more info: ViewModelProvider

To implement viewModel simply use val viewModel: MainViewModel by viewmodels()

if you use the same viewmodel in more than one place(acitity/fragment) in fragment use val viewModel: MainViewModel by activityViewModels()

Note: do not forget to update the dependencies. More info: ViewModel / SharedViewModel

About the Author

Question Info

Publish Time
2023-01-24 21:03
Update Time
2023-01-24 21:03