package Ġcom . ed im ari yan to . test mv vm . ui . auth Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . ed im ari yan to . test mv vm . data . models . auth . login . Login Request Ċ import Ġcom . ed im ari yan to . test mv vm . data . models . auth . login . Login Response Ċ import Ġcom . ed im ari yan to . test mv vm . data . network . Resources Ċ import Ġcom . ed im ari yan to . test mv vm . data . repository . Auth Repository Ċ import Ġcom . ed im ari yan to . test mv vm . ui . base . Base ViewModel Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠAuth ViewModel ( private Ġval Ġauth Repository : ĠAuth Repository ) Ġ: ĠBase ViewModel ( auth Repository ) Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ login Response : ĠMutable LiveData < Resources < Login Response >> Ġ= ĠMutable LiveData () ĊĠĠĠ Ġval Ġlogin Response : ĠLive Data < Resources < Login Response >> ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ login Response ĊĊĊĠĠĠ Ġfun Ġlogin ( userName : ĠString , Ġpassword : ĠString ) Ġ= ĠviewModel Scope . launch { ĊĠĠĠĠĠĠĠ Ġ_ login Response . value Ġ= ĠResources . Loading ĊĠĠĠĠĠĠĠ Ġ_ login Response . value Ġ= Ġauth Repository . login ( Login Request ( password , ĠuserName )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġsave Token ( token : ĠString ){ ĊĠĠĠĠĠĠĠ Ġauth Repository . save Token ( token ) ĊĠĠĠ Ġ} Ċ }