package Ġcom . example . sample data app . view model Ċ Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġcom . example . sample data app . data . Repository Ċ Ċ class ĠMain ViewModel Factory ( private Ġval Ġrepository : ĠRepository ) Ġ: ĊĠĠĠ ĠViewModel Provider . New Instance Factory () Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġ< T Ġ: ĠViewModel ?> Ġcreate ( model Class : ĠClass < T >): ĠT Ġ= ĠMain ViewModel ( repository ) Ġas ĠT Ċ } Ċ