Hello, thank you for your response! Yes, there is a nice and clean way to cover the scenario you described.

Let’s start with the view state:

data class Country(val name: String)data class CountriesViewState(val countriesList: List<Country> = emptyList())

Then create intent for loading countries:

sealed class CountriesIntent : Intent {object LoadCountries: CountriesIntent()}

In your fragment, let’s override the “emitIntents” method:

override fun emitIntents(): Observable<CountriesIntent> = Observable.merge(listOf(Observable.just(CountriesIntent.LoadCountries)))

This approach will emit “LoadCountries” intent when the fragment onResume method will be called.

Then in presenter:

override fun intentToPartialState(intent: CountriesIntent): Observable<CountriesPartialState> {val oldViewState = getViewState()return when (intent) {is CountriesIntent.LoadCountries -> loadCountriesIfNeeded(oldViewState)}}

And

private fun loadCountriesIfNeeded(oldViewState: CountriesViewState): Observable<CountriesPartialState> =when {oldViewState.countriesList.isEmpty() -> countriesSource().map {CountriesPartialState.CountriesLoaded(it)}else -> Observable.never()}

And

private fun countriesSource(): Observable<List<Country>> = Observable.just(listOf(Country(“Poland”)))

So we are checking if the list is already loaded or not. If the list is empty, we are loading a new one, if the list is already loaded and not empty, we are not emitting any new partial state.

The partial state will look like:

sealed class CountriesPartialState : PartialState<CountriesViewState, CountriesViewEffect> {data class CountriesLoaded(private val countriesList: List<Country>) : CountriesPartialState() {override fun reduce(previousState: CountriesViewState): CountriesViewState {return previousState.copy(countriesList = countriesList)}}}

and the last thing — render method in the fragment:

override fun render(viewState: CountriesViewState) {// take this data and display on the view (using recyclerview or something)viewState.countriesList}

The technology partner for growing businesses. We help companies to build software, websites, and apps. Visit amsterdamstandard.com for more information.

The technology partner for growing businesses. We help companies to build software, websites, and apps. Visit amsterdamstandard.com for more information.