package Ġcom . cost ular . mar vel hero es . data . repository Ċ Ċ import Ġcom . cost ular . mar vel hero es . data . repository . datasource . Remote Mar vel Hero es DataSource Ċ import Ġcom . cost ular . mar vel hero es . data . model . Mar vel Hero Entity Ċ import Ġcom . cost ular . mar vel hero es . data . repository . datasource . Local Mar vel Hero es DataSource Ċ import Ġio . reactivex . Flow able Ċ Ċ /** Ċ Ġ* ĠCreated Ġby Ġcost ular Ġon Ġ 1 7 / 0 3 / 2 0 1 8 . Ċ Ġ*/ Ċ class ĠMar vel Hero es Repository Ġ( private Ġval Ġlocal Mar vel Hero es DataSource : ĠLocal Mar vel Hero es DataSource , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġremote Mar vel Hero es DataSource : ĠRemote Mar vel Hero es DataSource ) Ġ{ ĊĊĠĠĠ Ġfun Ġget Mar vel Hero ( name : ĠString ): ĠFlow able < Mar vel Hero Entity > Ġ= Ġlocal Mar vel Hero es DataSource . get Mar vel Hero ( name ) ĊĊĠĠĠ Ġfun Ġget Mar vel Hero es List (): ĠFlow able < List < Mar vel Hero Entity >> Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Mar vel Hero es From Db (). concat With ( get Mar vel Hero es From Remote ()) ĊĊĠĠĠ Ġfun Ġupdate Mar vel Hero ( hero : ĠMar vel Hero Entity ) Ġ= Ġlocal Mar vel Hero es DataSource . update Mar vel Hero ( hero ) ĊĊĠĠĠ Ġprivate Ġfun Ġget Mar vel Hero es From Db (): ĠFlow able < List < Mar vel Hero Entity >> Ġ= Ġlocal Mar vel Hero es DataSource . get Mar vel Hero es List () ĊĊĠĠĠ Ġprivate Ġfun Ġget Mar vel Hero es From Remote (): ĠFlow able < List < Mar vel Hero Entity >> Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġremote Mar vel Hero es DataSource . get Mar vel Hero es List () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. do On Next { local Mar vel Hero es DataSource . save Mar vel Hero es ( it )} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. onError Resume Next ( get Mar vel Hero es From Db ()) Ċ Ċ }