在Android项目MVVM中,将ItemsPagingSource文件放在哪里?

huangapple go评论88阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年3月9日 20:12:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75684454.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定