private val mCompositeDisposable = CompositeDisposable() override fun unsubscribe() { mCompositeDisposable.clear() } override fun getMovies() { requestMovies() } private fun requestMovies(){ ... } } Presenter - The Home Presenter
private val mCompositeDisposable = CompositeDisposable() override fun unsubscribe() { mCompositeDisposable.clear() } override fun getMovies() { requestMovies() } private fun requestMovies(){ ... } } Presenter - The Home Presenter ❌ Don’t let Presenters know about Android framework classes
private val mCompositeDisposable = CompositeDisposable() override fun unsubscribe() { mCompositeDisposable.clear() } override fun getMovies() { requestMovies() } private fun requestMovies(){ ... } } Presenter - The Home Presenter class HomePresenter (private val dataManager: DataManager) : BasePresenter<HomeView>(), HomeContract.ViewActions { override fun getMovies() { requestMovies() } private fun requestMovies(){ ... }
MutableLiveData<List<Student>> students; public LiveData<List<Student>> getStudents() { if (students == null) { students = new MutableLiveData<List<Student>>(); loadStudents(); } return students; } private void loadStudents() { // Do an asyncronous operation to fetch users. } }