package Ġorg . ny pl . simpl ified . main Ċ Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġhu . ak arn ok d . rx java 2 . subjects . Un icast Work Subject Ċ import Ġio . reactivex . android . schedul ers . Android Schedulers Ċ import Ġio . reactivex . dis pos ables . Composite Disposable Ċ import Ġorg . library simpl ified . services . api . Services Ċ import Ġorg . ny pl . simpl ified . accounts . api . Account Event Ċ import Ġorg . ny pl . simpl ified . accounts . registry . api . Account Provider Registry Type Ċ import Ġorg . ny pl . simpl ified . build config . api . Build Configuration ServiceType Ċ import Ġorg . ny pl . simpl ified . profiles . api . Profile Event Ċ import Ġorg . ny pl . simpl ified . profiles . controller . api . Profiles Controller Type Ċ Ċ /** Ċ Ġ* ĠThe Ġview Ġmodel Ġfor Ġthe Ġmain Ġfragment . Ċ Ġ*/ Ċ Ċ class ĠMain Fragment ViewModel Ġ: ĠViewModel () Ġ{ ĊĊĠ Ġval Ġaccount Events : ĠUn icast Work Subject < Account Event > Ġ= ĊĠĠĠ ĠUn icast Work Subject . create () ĊĠ Ġval Ġprofile Events : ĠUn icast Work Subject < Profile Event > Ġ= ĊĠĠĠ ĠUn icast Work Subject . create () ĊĊĠ Ġprivate Ġval Ġservices Ġ= ĊĠĠĠ ĠServices . service Directory () ĊĠ Ġval Ġprofiles Controller Ġ= ĊĠĠĠ Ġservices . require Service ( Profiles Controller Type :: class . java ) ĊĠ Ġval Ġaccount Providers : ĠAccount Provider Registry Type Ġ= ĊĠĠĠ Ġservices . require Service ( Account Provider Registry Type :: class . java ) ĊĠ Ġval Ġbuild Config Ġ= ĊĠĠĠ Ġservices . require Service ( Build Configuration ServiceType :: class . java ) ĊĊĠ Ġprivate Ġval Ġsubscriptions : ĠComposite Disposable Ġ= ĊĠĠĠ ĠComposite Disposable () ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġprofiles Controller . account Events () ĊĠĠĠĠĠ Ġ. observe On ( Android Schedulers . main Thread ()) ĊĠĠĠĠĠ Ġ. subscribe ( this :: on Account Event ) ĊĠĠĠĠĠ Ġ. let Ġ{ Ġsubscriptions . add ( it ) Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġon Account Event ( event : ĠAccount Event ) Ġ{ ĊĠĠĠ Ġaccount Events . onNext ( event ) ĊĠ Ġ} ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġthis . profiles Controller . profile Events () ĊĠĠĠĠĠ Ġ. observe On ( Android Schedulers . main Thread ()) ĊĠĠĠĠĠ Ġ. subscribe ( this :: on Profile Event ) ĊĠĠĠĠĠ Ġ. let Ġ{ Ġsubscriptions . add ( it ) Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġon Profile Event ( event : ĠProfile Event ) Ġ{ ĊĠĠĠ Ġprofile Events . onNext ( event ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Cle ared () Ġ{ ĊĠĠĠ Ġsuper . on Cle ared () ĊĠĠĠ Ġsubscriptions . clear () ĊĠ Ġ} Ċ } Ċ