How to chain an Observable with a Single in RxJava?

I am new to the Rx world so please bear with me.

My code is in Kotlin but a Java code will help also.

I have 2 methods, one of them loads tasks from the database, if there are tasks, I want to send them to the server.

fun getListFromDb(): Single<List<TaskEntity>> {
    return taskEntityDao.getAll()
}

 fun syncTasks(localTasks: TaskSyncRequest): Observable<ApiResponse<List<TaskEntity>>> {
    return taskServices.syncTasks(localTasks)
}

I know I can use flatmap to chain observables, but just couldn't get it working between Single and Observables.

Upvotes: 0

Views: 3344

Answers (1)

Vova
Vova

Reputation: 1091

Try to use flatMapObservable You can use this method for transform single to observable;

Upvotes: 3

Related Questions