I want to repeat fetch data from network until all...
# rx
v
I want to repeat fetch data from network until all data downloaded. What I’m doing is this below code. It works fine, but I want to make sure I’m doing it the correct way, please advise.
Copy code
val networkRequest = API.fetch() // Returns observable of data
        Observable
                .defer {
                    networkRequest
                }
                .takeWhile {
                    !allDataFetched
                }
                .repeat()
                .subscribe {
                    // Do cool things, e.g. store to database and update `allDataFetched` flag
                }