package Ġcom . eig end ak sh . trend ing repositories . screens Ċ Ċ import Ġcom . eig end ak sh . trend ing repositories . R Ċ import Ġcom . eig end ak sh . trend ing repositories . di . Screen Scope Ċ import Ġcom . eig end ak sh . trend ing repositories . model . Repo Ċ import Ġcom . jak ew h art on . rx relay 2 . Behavior Relay Ċ import Ġio . reactivex . Observable Ċ import Ġio . reactivex . functions . Consumer Ċ import Ġtim ber . log . Tim ber Ċ import Ġjavax . inject . Inject Ċ Ċ @ Screen Scope Ċ class ĠT rend ing Repos ViewModel Ġ@ Inject Ġconstructor () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġrepos Relay Ġ= ĠBehavior Relay . create < List < Repo >>() ĊĠĠĠ Ġprivate Ġval Ġerror Relay Ġ= ĠBehavior Relay . create < Int >() ĊĠĠĠ Ġprivate Ġval Ġloading Relay Ġ= ĠBehavior Relay . create < Boolean >() ĊĊĠĠĠ Ġ// ĠEx pose Ġas ĠObservable s Ġto ĠView ( s ) ĊĠĠĠ Ġfun Ġget Loading (): ĠObservable < Boolean > Ġ= Ġloading Relay ĊĊĠĠĠ Ġfun Ġget Repos (): ĠObservable < List < Repo >> Ġ= Ġrepos Relay ĊĊĠĠĠ Ġfun Ġget Error (): ĠObservable < Int > Ġ= Ġerror Relay ĊĊĊĠĠĠ Ġ// ĠEx pose Ġas Ġconsumer Ġto Ġoutside ĊĠĠĠ Ġfun Ġset Loading (): ĠConsumer < Boolean > Ġ= Ġloading Relay ĊĊĠĠĠ Ġfun Ġset Repos (): ĠConsumer < List < Repo >> Ġ{ ĊĠĠĠĠĠĠĠ Ġerror Relay . accept (- 1 ) ĊĠĠĠĠĠĠĠ Ġreturn Ġrepos Relay ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun ĠonError (): ĠConsumer < Throwable > Ġ= ĠConsumer Ġ{ ĊĠĠĠĠĠĠĠ ĠTim ber . e ( it , Ġ" Error Ġloading Ġrepos ") ĊĠĠĠĠĠĠĠ Ġerror Relay . accept ( R . string . api _ error _ repos ) ĊĠĠĠ Ġ} Ċ }