在 MVP(模型 View 演示器)模式中,使用基础 View 和演示器是常见的做法。我们可以省略它们吗?为什么我们首先要使用它?
最佳答案
使用 BaseView
和 BasePresenter
的原因是将通用方法从子级移动到父级,因为假设您的大多数 View 都有 showProgress()
方法,你可以停止在每个 child 中声明它并像在
interface BaseView{
void showProgress();
}
interface SomeView extends BaseView{
void someAction();
}
interface OtherView extends BaseView{
void otherAction();
}
interface NoProgressView { // this view doesn't need progress so avoid extedning
void dummyAction();
}
关于android - 为什么我们使用 Base View 和 Base Presenter 来实现 MVP 模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49687738/