pass arguments to viewmodel android kotlin using koin 1

pass arguments to viewmodel android kotlin using koin

viewModel{ params -> AlbumViewModel(artistId = params.get(), playlistId = params.get()) }
}
val a = anyObject
val b = anyObject
val albumvieModle  = AlbumViewModel by inject { parametersOf(a, b) 

Here is what the above code is Doing:
1. We’re creating a factory function that takes two parameters and returns an AlbumViewModel.
2. We’re creating two variables a and b.
3. We’re injecting an AlbumViewModel by passing the two variables a and b as parameters to the factory function.

Similar Posts