andre.artus
05/29/2018, 4:18 AMmodel = getViewModel(parameters = { mapOf("itemId" to itemId) })
I'm sharing the viewmodel with the detail fragment so that (in theory) it only needs to load once.
I tried
model = getSharedViewModel()
But it fails with:
Caused by: org.koin.error.BeanInstanceCreationException: Can't create bean Factory[class=za.co.ruggedmobile.petermetertest.ui.meters.MetersViewModel, binds~(android.arch.lifecycle.ViewModel)] due to error :
kotlin.TypeCastException: null cannot be cast to non-null type <http://kotlin.Int|kotlin.Int>
arnaud.giuliani
05/29/2018, 8:38 AMandre.artus
05/29/2018, 9:56 AMandre.artus
05/29/2018, 9:56 AMandre.artus
05/29/2018, 9:57 AMandre.artus
05/29/2018, 9:57 AMarnaud.giuliani
05/29/2018, 10:21 AMby viewModel()
in your fragmentarnaud.giuliani
05/29/2018, 10:21 AMandre.artus
05/29/2018, 11:00 AMandre.artus
05/29/2018, 11:03 AMgetViewModel
in main fragment, and by viewModel
in nested, is this right?andre.artus
05/29/2018, 11:11 AMarnaud.giuliani
05/29/2018, 11:47 AMandre.artus
05/29/2018, 11:59 AMandre.artus
05/29/2018, 12:03 PMchildFragmentManager
and a setViewModel
method on the nested fragment, but that seems like a hack.andre.artus
05/29/2018, 12:04 PMandre.artus
05/29/2018, 12:40 PMchildFragmentManager.findFragmentById
in the master fragment to pass the id down with a public setID() method on the nested fragment.arnaud.giuliani
05/29/2018, 2:03 PMandre.artus
05/29/2018, 4:50 PM