Last active
July 30, 2018 16:38
-
-
Save JorgeCastilloPrz/07fbe258103b743d7559c6b72b655db0 to your computer and use it in GitHub Desktop.
RxTaskRepository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TaskRepository(private val localDS: DataSource, | |
private val remoteDS: RemoteDataSource) { | |
fun allTasksByUser(user: User): Observable<List<Task>> = | |
localDS.allTasksByUser(user) | |
.subscribeOn(Schedulers.io()) | |
.observeOn(Schedulers.computation()) | |
.onErrorResumeNext { _: Throwable -> remoteDS.allTasksByUser(user) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment