package Ġbu jj wo le . tin news . ui . home Ċ Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . Transform ations Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġbu jj wo le . tin news . model . Article Ċ import Ġbu jj wo le . tin news . repository . News Repository Ċ Ċ class ĠHome ViewModel ( val Ġnews Repository : ĠNews Repository ): ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġcountry Input : ĠMutable LiveData < String > Ġ= ĠMutable LiveData < String >() ĊĊĠĠĠ Ġfun Ġset Country Input ( country : ĠString ) Ġ= Ġcountry Input . setValue ( country ) ĊĊĠĠĠ Ġfun Ġget Top Head lines () Ġ= ĠTransform ations . switch Map ( country Input , Ġnews Repository :: get Top Head lines ) ĊĊĠĠĠ Ġfun Ġset Favorite Article Input ( article : ĠArticle ) Ġ= Ġnews Repository . favorite Article ( article ) Ċ }