I have this specific issue for which I cannot find a clean solution.
Observable.interval(1, TimeUnit.SECONDS)
.flatMap { constructData() }
.subscribe { data ->
api.syncData(data)
.repeat()
.subscribe { response ->
deleteSyncedData(data)
}
}
So as you can see from the code I need to construct some data package to send it to the backend and after it is correctly sent I'm deleting it from my local storage system. Right now it's working but looks a little bit like callback hell - what if I wanted to combine response with data and then make a request?
Does anyone see a better solution for this kind of operation?
Additionally I'd like to know how to switch between schedulers between those operations? I want to execute constructData()
and deleteSyncedData()
on Schedulers.computation()
but api.syncData(data)
on Schedulers.io()
.