How to perform a room transaction usin Rxjava

Viewed 815

How can I do a room transaction across 2 different DAOs usin rxjava?

I have this code that I would like to use with Rxjava but I need it to return some kind of observable

 @Transaction
fun insertStoreWithPictures(store: Store, pictures: List<StorePicture>) {

    insertStore(store)
    insertPictures(pictures)

}

The store DAO

@Dao
abstract public class store {

@Insert
Single<Long> insert(store  entity);
}

The storePicture DAO

@Dao
abstract public class storePicture {

    @Insert
    Completable insert(storePicture... entity);
}
2 Answers

I think you can use zip or combine operator of RxJava. It would create an observable from an iterators observable source.

Related