Skip to content

Instantly share code, notes, and snippets.

@ahmedMubarak2024
Created July 28, 2022 08:47
Show Gist options
  • Save ahmedMubarak2024/4ee7b734c60655e740f1de7af0f6855a to your computer and use it in GitHub Desktop.
Save ahmedMubarak2024/4ee7b734c60655e740f1de7af0f6855a to your computer and use it in GitHub Desktop.
simple view model factory
@Suppress("UNCHECKED_CAST")
class TasksViewModelFactory (/*pass the pram you need*/ ) : ViewModelProvider.NewInstanceFactory() {
override fun <T : ViewModel> create(modelClass: Class<T>) =
(ViewModel(/*pass the pram to view model*/) as T)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment