In Android presenter code, I see something like th...
# android-architecture
b
In Android presenter code, I see something like this, where
isFetching
is a class variable which holds network data fetching state. Is this a good pattern? I was trying to remove this class variable to reduce state in presenter. Is that possible or will it be an overkill?
Copy code
override fun fetchData() : {
  if(isFetching) return

  isFetching = true
  apiService
       .fetchData()
       .doOnFinally { isFetching = false }
       .subscribe({ 
          view?.updateData()
        }, { })
}
k
You might want to read about mvp with clean architecture. Presenter is not a right place to do fetching data. Presenter should be independent to android framework. It can get dâta from model layer. For more details you can pm me we could discuss
b
@KayCee In Presenter, I'm not using any android component. It is completely independent from Android framework code..
view
is an interface implemented by Activity/fragment.
k
so in your presenter constructor, you have a reference of
apiService
? The main thing is you do the fetching job in presenter, why?
b
No no, this was just an example. Presenter has Repository and repository takes care of loading from local or remote store..