Here’s how our Kotlin code looks: class PostListViewModel(įun getAllPosts(userId: Int, callback: PostDataSource. We’ll get into that in more detail soon, but in this architecture, a UseCase is an action that defines how a ViewModel interacts with the data layer. On the right there is a checkbox and after clicking on the checkbox at the bottom, the button bar appears. Click on the button it shows at the bottom more buttons. The goal should be to click on the ListView line or on the button. Here we are passing a UseCaseHandler and two UseCases to our ViewModel. 60 I want to display a Button inside the ListView. A ViewModel never talks to the data layer directly. Never put your business logic in Activitys.Īn Activity will talk to a ViewModel and a ViewModel will talk to the domain layer to perform actions. An Activity should be as dumb as possible. This includes our Activitys, Fragments, and ViewModels. You are free to choose whatever project structure suits you. I like to group project files based on features.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |