package Ġuk . co . v ict oria jan ed avis . chat app . domain . inter actors Ċ Ċ import Ġjavax . inject . Inject Ċ Ċ import Ġio . reactivex . Comp letable Ċ import Ġio . reactivex . Observable Ċ import Ġio . reactivex . Single Ċ import Ġuk . co . v ict oria jan ed avis . chat app . data . repositories . Received Friend Request Repository Ċ import Ġuk . co . v ict oria jan ed avis . chat app . domain . entities . Friend ship Entity Ċ import Ġuk . co . v ict oria jan ed avis . chat app . domain . inter actors . Reactive Interactor . Retrieve Interactor Ċ Ċ import Ġio . reactivex . Single . just Ċ import Ġuk . co . v ict oria jan ed avis . chat app . domain . common . Stream State Ċ import Ġuk . co . v ict oria jan ed avis . chat app . domain . common . to Stream State Ċ Ċ class ĠGet Received Friend Requests List Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġrepository : ĠReceived Friend Request Repository Ċ ) Ġ: ĠRetrieve Interactor < Void , ĠStream State < List < Friend ship Entity >>> Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġget Behavior Stream ( params : ĠVoid ?): ĠObservable < Stream State < List < Friend ship Entity >>> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġrepository . all Received Friend Requests () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. switch Map Single (:: fetch When Empty And Then Received Friend Requests ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġfetch When Empty And Then Received Friend Requests ( ĊĠĠĠĠĠĠĠ Ġfriend Entities : ĠList < Friend ship Entity > ĊĠĠĠ Ġ): ĠSingle < Stream State < List < Friend ship Entity >>> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġfetch When Empty ( friend Entities ). and Then ( just ( friend Entities )). to Stream State () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġfetch When Empty ( friend Entities : ĠList < Friend ship Entity >): ĠComp letable Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġif Ġ( friend Entities . isEmpty ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . fetch Received Friend Requests () ĊĠĠĠĠĠĠĠ Ġelse ĊĠĠĠĠĠĠĠĠĠĠĠ ĠComp letable . complete () ĊĠĠĠ Ġ} Ċ } Ċ