I don’t think using map
operator is the best way to go with things like storing the result of the api call.
What I like to do is to separate those things inside doOnNext
operators. So your example would be something like this:
apiService.A()
.doOnNext(modelA -> db.store(modelA))
.flatMap(modelA -> apiService.B())
.doOnNext(modelB -> db.store(modelB));
(add necessary observeOn
and subscribeOn
yourself, exactly like you need them)