package Ġd roid ka igi . github . io . challenge 2 0 1 9 . story . detail Ċ Ċ import Ġandroidx . databinding . Observable Field Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġd roid ka igi . github . io . challenge 2 0 1 9 . domain . Load State . Loading Ċ import Ġd roid ka igi . github . io . challenge 2 0 1 9 . domain . Story Ċ import Ġd roid ka igi . github . io . challenge 2 0 1 9 . service . Story Service Ċ import Ġio . reactivex . Single Ċ Ċ class ĠStory Detail Activity ViewModel ( ĊĠĠĠ Ġprivate Ġval Ġstory Service : ĠStory Service , ĊĠĠĠ Ġprivate Ġval Ġstory : ĠStory Ċ ) Ġ: ĠViewModel () Ġ{ ĊĠĠĠ Ġval ĠisLoading : ĠObservable Field < Boolean > Ġ= ĊĠĠĠĠĠĠĠ ĠObservable Field ( story Service . load State . value Ġ== ĠLoading ). also Ġ{ Ġfield Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstory Service . load State . subscribe Ġ{ Ġfield . set ( it Ġ== ĠLoading ) Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġread (): ĠSingle < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġstory Service . read ( story ). to Single Ġ{ Ġtrue Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Comments (): ĠSingle < List < Comment ViewModel >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġstory Service . get Comments ( story ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġit . map (:: Comment ViewModel ) Ġ} ĊĠĠĠ Ġ} Ċ } Ċ