edward
01/26/2022, 8:40 PMclass ListFragment : Fragment() {
// Using the activityViewModels() Kotlin property delegate from the
// fragment-ktx artifact to retrieve the ViewModel in the activity scope
private val viewModel: ItemViewModel by activityViewModels()
wtf is activityViewModels?Arilson JosĂ© de Oliveira JĂșnior
01/26/2022, 8:52 PMfactoryProducer is specified then ViewModelProvider.Factory returned by it will be used to create ViewModel first time. Otherwise, the activityâs androidx.activity.ComponentActivity.getDefaultViewModelProviderFactory will be used.Arilson JosĂ© de Oliveira JĂșnior
01/26/2022, 9:01 PMactivityViewModels() is a delegation used to create or access an instance of ViewModel by the lazy wayArilson JosĂ© de Oliveira JĂșnior
01/26/2022, 9:02 PMArilson JosĂ© de Oliveira JĂșnior
01/26/2022, 9:02 PMedward
01/26/2022, 9:14 PMArilson JosĂ© de Oliveira JĂșnior
01/26/2022, 9:21 PMviewModel() or sharedViewModel() delegate. Read something about that.zsmb
01/27/2022, 9:40 AMactivityViewModels and `viewModels`:
https://developer.android.com/reference/kotlin/androidx/fragment/app/package-summary#(androidx.fragment.app.Fragmen[âŠ]tyViewModels(kotlin.Function0)
https://developer.android.com/reference/kotlin/androidx/fragment/app/package-summary#(androidx.fragment.app.Fragmen[âŠ]in.Function0,kotlin.Function0)