英文:
Where to place the ItemsPagingSource file in Android project MVVM?
问题
我已经在我的Android项目中使用MVVM架构。这是项目结构:
src
\_ domain
\_ model
\_ repository
\_ ItemsRepository
\_ data
\_ repository
\_ ItemsRepositoryImpl
\_ presentations
\_ items
\_ ItemsScreen
\_ ItemsViewModel
今天,我已经实现了分页功能,并创建了一个名为ItemsPagingSource
的类。在这个结构中,我应该将这样一个文件放在哪里,以不违反MVVM规则?
英文:
I have an Android project where I use MVVM. This is the structure:
src
\_ domain
\_ model
\_ repository
\_ ItemsRepository
\_ data
\_ repository
\_ ItemsRepositoryImpl
\_ presentations
\_ items
\_ ItemsScreen
\_ ItemsViewModel
Today I have implemented pagination and I have created a ItemsPagingSource
class. Where in this structure should I place such a file to not break MVVM rules?
答案1
得分: 1
PagingSource
是数据的来源,因此它应该放在数据层。
也许是 src/data/repository
。
或者是 src/data/paging
,如果你想更细化。
不过,就代码组织而言,关于“MVVM规则”并没有具体的规定可以违反。这完全取决于你个人(或团队)的偏好,以便以对你来说最合乎逻辑的方式组织代码。
英文:
> Where in this structure should I place such a file to not break MVVM rules?
PagingSource
is a source of data - hence it would go with your data layer.
Maybe src/data/repository
.
Or src/data/paging
if you want to get granular.
That said, there are no "MVVM rules" for you to break as far as organizing your code. That's up to your personal (or team) preference to organize things in the way that's most logical for you.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论