package Ġcom . alam kan ak . week view . sample . ui . async Ċ Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġcom . alam kan ak . week view . sample . data . Events Api Ċ import Ġcom . alam kan ak . week view . sample . data . model . Api Event Ċ Ċ internal Ġdata Ġclass ĠAsync ViewState ( ĊĠĠĠ Ġval Ġevents : ĠList < Api Event > Ġ= Ġempty List (), ĊĠĠĠ Ġval ĠisLoading : ĠBoolean Ġ= Ġfalse Ċ ) Ċ Ċ internal Ġclass ĠAsync ViewModel ( ĊĠĠĠ Ġprivate Ġval Ġevents Api : ĠEvents Api Ċ ) Ġ{ ĊĊĠĠĠ Ġval Ġview State Ġ= ĠMutable LiveData < Async ViewState >() ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġfetch Events () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġfetch Events () Ġ{ ĊĠĠĠĠĠĠĠ Ġview State . value Ġ= ĠAsync ViewState ( isLoading Ġ= Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġevents Api . fetch Events Ġ{ Ġevents Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview State . value Ġ= ĠAsync ViewState ( events Ġ= Ġevents , ĠisLoading Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġremove ( event : ĠApi Event ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġall Events Ġ= Ġview State . value ?. events Ġ?: Ġreturn ĊĠĠĠĠĠĠĠ Ġview State . value Ġ= ĠAsync ViewState ( events Ġ= Ġall Events . minus ( event )) ĊĠĠĠ Ġ} Ċ } Ċ