-
Notifications
You must be signed in to change notification settings - Fork 12
перевод на Mvvm #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…. в useCase перенесена ссылка репозиторий, чтобы презентор работал не через репозитрий напрямую а через useCase
|
||
interface MvvmContract { | ||
|
||
val listPosts: MutableLiveData<List<Post>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше наружу выводить LiveData а не мутабельную. Вью не должна ничего постить во вьюмодель
|
||
private val repository: IRepository = Repository() | ||
|
||
fun loadPosts(listPosts: MutableLiveData<List<Post>>, errorMessage: MutableLiveData<Throwable>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше не нагружать юзкейс ещё логикой передачи данных во вьюмодель. Лучше просто получат их из источника и сортирует, а про то как их передать на вью, лучше пусть думает вьюмодель
import com.example.architecturebase.UseCases.UseCaseGetPosts | ||
import com.example.architecturebase.network.model.Post | ||
|
||
class ViewModelMvvm : LifecycleObserver, MvvmContract { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нужно отнаследоваться именно от ViewModel от google
…ределил binding по красоте, ViewModelMvvm.kt теперь сама обрабатывет запросы из UseCaseGetPosts.kt, ViewModelMvvm.kt, наследуется от ViewModel, обнавлен MvvmContract.kt чтобы фрагмент не мог изменять LiveData
No description provided.