Matti MK
11/17/2021, 11:52 AMKoin
as shown below.
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module
actual val myScreenModule = module {
viewModel { MyScreen() }
}
The VM itself extends import androidx.lifecycle.ViewModel
class.
And inside my NavGraphBuilder.addMainGraph
block I instantiate the screen
composable(MyScreen.route) {
MyScreen(
viewModel = get(),
)
}
Not quite sure how to go about things here: is this expected behaviour and I should store VM state inside or is there some other way that I could keep the state?Csaba Kozák
11/17/2021, 12:00 PMgetViewModel()
function. See here.Matti MK
11/17/2021, 12:02 PMMatti MK
11/17/2021, 12:02 PM