package Ġcom . nel ipa . home ass ig ment . applic aster . storage Ċ Ċ import Ġcom . nel ipa . home ass ig ment . applic aster . di . scope . App Scope Ċ import Ġcom . nel ipa . home ass ig ment . applic aster . managers . contract . Network Manager Ċ import Ġcom . nel ipa . home ass ig ment . applic aster . models . Post Entry Ċ import Ġcom . nel ipa . home ass ig ment . applic aster . storage . local . Posts Dao Ċ import Ġio . reactivex . Comp letable Ċ import Ġio . reactivex . Observable Ċ import Ġio . reactivex . rx kotlin . Sing les Ċ import Ġio . reactivex . schedul ers . Schedulers Ċ import Ġjavax . inject . Inject Ċ Ċ @ App Scope Ċ class ĠPosts Repository Impl Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġnetwork Manager : ĠNetwork Manager , ĊĠĠĠ Ġprivate Ġval Ġposts Dao : ĠPosts Dao Ċ ) Ġ: ĠPosts Repository Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġload Posts () Ġ= ĠSing les . zip ( ĊĠĠĠĠĠĠĠ Ġnetwork Manager . get Links (), ĊĠĠĠĠĠĠĠ Ġnetwork Manager . get Videos () ĊĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ. flatMap Comp letable Ġ{ Ġ(_ links , Ġ_ videos ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠComp letable . concat Array ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġposts Dao . insert All (_ links ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġposts Dao . insert All (_ videos ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ. subscribe On ( Schedulers . io ()) ĊĊĠĠĠ Ġoverride Ġfun Ġrefresh Posts () Ġ= Ġload Posts () ĊĠĠĠĠĠĠĠ Ġ. start With ( posts Dao . delete All Posts ()) ĊĠĠĠĠĠĠĠ Ġ. subscribe On ( Schedulers . io ()) ĊĊĠĠĠ Ġoverride Ġfun Ġobserve All Posts (): ĠObservable < List < Post Entry >> Ġ= Ġposts Dao . getAll Post Entries () ĊĊĠĠĠ Ġoverride Ġfun Ġobserve Posts Filtered By ( query : ĠString ): ĠObservable < List < Post Entry >> Ġ= Ġposts Dao . get Posts Containing ("% $ query % ") Ċ }