package Ġcom . kat ari ya . new son . network . view model Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . kat ari ya . new son . network . model . Article Ċ import Ġcom . kat ari ya . new son . network . model . News Info Data Ċ import Ġcom . kat ari ya . new son . network . repository . Ret rofit Repository Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠNews ViewModel ( ret rofit Repository : ĠRet rofit Repository ): ĠViewModel () Ġ{ ĊĊĠĠĠ Ġvar Ġretrofit Repository : Ret rofit Repository Ġ= Ġretrofit Repository ĊĠĠĠ Ġvar Ġresponse LiveData : ĠLive Data < ArrayList < Article >> Ġ= ĠMutable LiveData () ĊĠĠĠ Ġvar Ġloading LiveData : ĠLive Data < Boolean > Ġ= ĠMutable LiveData () ĊĠĠĠ Ġvar Ġerror LiveData : ĠLive Data < String > Ġ= ĠMutable LiveData () ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġfetch News From Repository () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfetch News From Repository (){ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch { ĊĠĠĠĠĠĠĠĠĠĠĠ Ġretrofit Repository . fetch Post InfoList () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse LiveData Ġ= Ġ Ġretrofit Repository . response LiveData ĊĠĠĠĠĠĠĠĠĠĠĠ Ġloading LiveData Ġ= Ġretrofit Repository . loading LiveData ĊĠĠĠĠĠĠĠĠĠĠĠ Ġerror LiveData Ġ= Ġretrofit Repository . error LiveData ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊ Ċ }