I want to concat different observables to create an activity flow, using SQLBrite to persist informations into my android sqlite database
This flow have to follow this sequence of avtivities:
1 - Create an observable responsible to open an instance of transaction
2 - concat many observables, each one responsible to insert data into tables (one observable per table)
3.a - if every data are inserted as well (doOnCompleted method), log this and set my transaction instance as successful
3.b - if has an error, log this error (doOnError method)
4 - Close my transaction instance (doOnTeminate method)
The problem:
Methods like doOnError, doOnCompleted and doOnTerminate doesn't send my transaction instance as parameter. There is an way to do that?
I don't believe you gain anything by making the action of opening a connection an observable. Here's a simpler way to solve your problem.
SomeObject transaction=new Transaction();
Observable.concat(obs1,obs2,obs3)
.doOnCompleted(logStuff())
.doOnError(e->)
.doOnTerminate(transaction.close());